對象不支持find屬性或方法


由於ie瀏覽器不兼容,導致頁面數據渲染不出來:

 

 

ie瀏覽器不兼容find寫法,在引用的公共方法中添加兼容代碼,如下:

/*兼容處理 低版本IE*/
//
Array.prototype.find || (Array.prototype.find = function (predicate) { 
    if (this == null) {
      throw new TypeError('Array.prototype.find called on null or undefined');
    }
    if (typeof predicate !== 'function') {
      throw new TypeError('predicate must be a function');
    }
    var list = Object(this);
    var length = list.length || 0;
    var thisArg = arguments[1];
    var value;

    for (var i = 0; i < length; i++) {
      value = list[i];
      if (predicate.call(thisArg, value, i, list)) {
        return value;
      }
    }
    return null;
})

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM