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

 

转载于:https://www.cnblogs.com/godok/p/10109462.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值