Uncaught (in promise) Error: Duplicated key ‘uploadAttachment‘ in menu items

Let me first say that this bug was encountered after switching back and forth using the wangEditor rich text plug-in. First, check whether an attachment plug-in has been added to this component. If this attachment plug-in is added and the existence of the plug-in is not determined in the code, this will appear. Error because the attachment was registered twice. Solution:

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"], // “上传附件”菜单
  },
};

 

Guess you like

Origin blog.csdn.net/SunFlower914/article/details/130349352