微信小程序-Object.entries is not a fu

2019-04-26  本文已影响0人  匿于烟火中

原因:Object.entries is not a function.在部分机型小程序上不支持
ES6 Object.entries 部分机型不支持问题

方法:添加Object.entries polyfill
Object.entries polyfill

if (!Object.entries)
  Object.entries = function( obj ){
    var ownProps = Object.keys( obj ),
        i = ownProps.length,
        resArray = new Array(i); // preallocate the Array
    while (i--)
      resArray[i] = [ownProps[i], obj[ownProps[i]]];
    
    return resArray;
  };
上一篇 下一篇

猜你喜欢

热点阅读