1. 程式人生 > 實用技巧 >企業微信瀏覽器報錯Object.entries is not a function

企業微信瀏覽器報錯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-shimes6-shim等 Polyfills 的支援。

如果你使用了 babel,強烈推薦使用babel-polyfillbabel-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]]] : []), []); }; }