tangyuxian
文章65
标签33
分类5
微信小程序-Object.entries is not a function解决办法

微信小程序-Object.entries is not a function解决办法

在部分机型上打开开发的小程序,vcosole显示Object.entries is not a function这类错误,可以使用以下方法手动添加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;
  };
本文作者:tangyuxian
本文链接:https://www.tangyuxian.com/2021/02/20/%E5%89%8D%E7%AB%AF/%E5%BE%AE%E4%BF%A1%E5%B0%8F%E7%A8%8B%E5%BA%8F/%E5%BE%AE%E4%BF%A1%E5%B0%8F%E7%A8%8B%E5%BA%8F-Object.entries%20is%20not%20a%20function%E8%A7%A3%E5%86%B3%E5%8A%9E%E6%B3%95/
版权声明:本文采用 CC BY-NC-SA 3.0 CN 协议进行许可