企业微信浏览器报错Object.entries is not a function

引入antd后,企业微信浏览器报错Object.entries is not a function

在其他浏览器、微信开发者调试工具里都正常。当前企业微信版本3.0.21,打开企业微信调试模式,查看浏览器内核版本号是chrome 53

方法1:https://www.antdv.com/docs/vue/getting-started-cn/#%E5%85%BC%E5%AE%B9%E6%80%A7

对于 IE 系列浏览器,需要提供 es5-shim 和 es6-shim 等 Polyfills 的支持。

如果你使用了 babel,强烈推荐使用 babel-polyfill 和 babel-plugin-transform-runtime 来替代以上两个 shim。

避免同时使用 babel 和 shim 两种兼容方法,以规避 #6512 中所遇问题

 

方法2:直接在main.js中加入下面代码

const reduce = Function.bind.call(Function.call, Array.prototype.reduce);
const isEnumerable = Function.bind.call(Function.call, Object.prototype.propertyIsEnumerable);
const concat = Function.bind.call(Function.call, Array.prototype.concat);
const keys = Reflect.ownKeys;
if (!Object.entries) {
  Object.entries = function entries(O) {
    return reduce(keys(O), (e, k) => concat(e, typeof k === 'string' && isEnumerable(O, k) ? [[k, O[k]]] : []), []);
  };
}

 

posted @ 2020-08-07 16:48  小水皮  阅读(1267)  评论(0编辑  收藏  举报