windows PC企业微信中引入element白屏报错

697 阅读1分钟

开发的时候一直都使用的mac平台的企业微信,一直都是正常的。但是同事用windows平台的企业微信怎么都不开应用。 打开控制台发现是有个 __getOwnPropDescs 函数没有定义。

image.png

image.png

var __getOwnPropDescs = Object.getOwnPropertyDescriptors;

跟进去发现 没定义的函数就是Object对象下的 getOwnPropertyDescriptors 函数,于是尝试查询文档函数用法 自定义覆盖Object下的getOwnPropertyDescriptors函数

//在main.js 引入element之前执行下方代码
//判断是否是企业微信
if (navigator.userAgent.toLowerCase().indexOf("wechat") > -1) {
  Object.getOwnPropertyDescriptors = function(obj) {
    const result = {};
    for (let key of Reflect.ownKeys(obj)) {
      result[key] = Object.getOwnPropertyDescriptor(obj, key);
    }
    return result;
  };
}

bingo 成功运行