vue iview Select bug,在低版本瀏覽器中報錯


iview是個好東西,今天第一次試用,用來做了一個app,但是在安卓5.1各種報錯啊,頭痛的是不知道具體哪行代碼錯了,總是報錯undefined is not a function。

倒騰了半天,原來是iview的select中用了Array.find、array.findIndex方法。原來瀏覽器版本低了,不兼容這些JavaScript特性。果斷的給打上補丁就好了

if(typeof Array.includes == 'undefined'){
      Array.prototype.includes = function(obj){
        return this.indexOf(obj) >=0
      }
    }

    if(typeof Array.findIndex == 'undefined'){
      Array.prototype.findIndex = function(obj){
        for(var i in this){
          if(this[i] == obj){
            return i;
          }
        }
        return -1
      }
    }
    if(typeof Array.find == 'undefined'){
      Array.prototype.find = function(fn){
        for(var i in this){
          if(fn(this[i],i,this)== true){
            return this[i];
          }
        }
        return undefined;
      }
    }

 


免責聲明!

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



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