先说下这个bug是使用wangEditor富文本插件来回切换后遇到的,先看下有没有为这个组件增加附件插件,如果加了这个附件插件又没在代码中判断插件是否存在,就会出现这个错误,因为附件被重复注册了,解决办法:
import "@wangeditor/editor/dist/css/style.css"; // 引入 css
import { Editor, Toolbar } from "@wangeditor/editor-for-vue";
import { Boot } from "@wangeditor/editor";
import attachmentModule from "@wangeditor/plugin-upload-attachment";
// 注册。要在创建编辑器之前注册,且只能注册一次,一定要判断,不可重复注册。
if (Boot.plugins.length < 13) {
//判断如果已经插入进去,不在二次插入
Boot.registerModule(attachmentModule);
}
const toolbarConfig = {
insertKeys: {
index: 0, // 自定义插入的位置
keys: ["uploadAttachment"], // “上传附件”菜单
},
};