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; } }