早睡早起,方能养生
Sleep early rise early, way to keep healthy

ckeditor5在360,qq等浏览器报错Object.fromEntries is not a function 无法初始化编辑器

super
2022-04-28 20:04
views 4982

 

原因:Object.fromEntries 是ES10新提出的

 

 

而浏览器更新较慢,所以报错方法fromEntries未找到,那我们把这个方法定义一下即可

 

在帖子https://stackoverflow.com/questions/67550901/object-fromentries-is-not-a-function-error-when-using-chakra-ui-and-next-js 中,找到了github代码链接

 

https://github.com/feross/fromentries/blob/master/index.js

 

在我们的build\cdeditor.js中加入以下代码:

 

 

Object.fromEntries = function fromEntries (iterable) {
    return [...iterable].reduce((obj, [key, val]) => {
        obj[key] = val;
        return obj;
    }, {});
};

 

报错消失,编辑器正常加载

 

 

-------------

禁止转载



分享
0 条讨论
top