jeudi 1 février 2018

Need to solve the plotly javascript in my project

I have a problem with my project while executing the below code,

var l = t("object-assign");
       l(n.prototype, {
           instance: function(t, e) {
               t = (t || "gregorian").toLowerCase(), e = e || "";
               var r = this._localCals[t + "-" + e];
               if (!r && this.calendars[t] && (r = new this.calendars[t](e), this._localCals[t + "-" + e] = r), !r) throw (this.local.invalidCalendar || this.regionalOptions[""].invalidCalendar).replace(/\{0\}/, t);
               return r
           },
           newDate: function(t, e, r, n, i) {
               return (n = (null != t && t.year ? t.calendar() : "string" == typeof n ? this.instance(n, i) : n) || this.instance()).newDate(t, e, r)
           },
           substituteDigits: function(t) {
               return function(e) {
                   return (e + "").replace(/[0-9]/g, function(e) {
                       return t[e]
                   })
               }
           },
           substituteChineseDigits: function(t, e) {
               return function(r) {
                   for (var n = "", i = 0; r > 0;) {
                       var a = r % 10;
                       n = (0 === a ? "" : t[a] + e[i]) + n, i++, r = Math.floor(r / 10)
                   }
                   return 0 === n.indexOf(t[1] + e[1]) && (n = n.substr(1)), n || t[0]
               }
           }
       })

The below error occuring while executing the above javascript files

Uncaught TypeError: t.calendar is not a function
  at s._validate (rsuite.js:11415)
  at s.newDate (rsuite.js:11415)
  at Object.596../main (rsuite.js:11415)
  at i (rsuite.js:11415)
  at rsuite.js:11415
  at Object.615.world-calendars/dist/calendars/chinese (rsuite.js:11415)
  at i (rsuite.js:11415)
  at rsuite.js:11415
  at Object.616.../../constants/numerical (rsuite.js:11415)
  at i (rsuite.js:11415)

My problem is, it is working well in the outside of the project. But with in my product execution time, its showing the above error. Please guide me on this. Thanks in advance




1 commentaire:

  1. fix newDate function(this happens because of a global variable t that has a member year(caused by an external date lib) and a local param t of type number)
    newDate: function(t, e, r, n, i) {
    return (n = ((null != t && typeof(t)!="number" && t.year) ? t.calendar() : "string" == typeof n ? this.instance(n, i) : n) || this.instance()).newDate(t, e, r)
    }

    RépondreSupprimer