对于Uncaught Error: 无效的节点选择器:#content 的解决办法
来源:8-7 集成富文本插件wangeditor

出家人不打尼姑
2022-01-20
以新增按钮为例
// 初始化富文本
let editor:any;
const createEditor = () => {
editor = new E('#content');
editor.highlight = hljs;
editor.create();
}
// 新增按钮
const add = () => {
modalVisible.value = true;
doc.value = {
ebookId: route.query.ebookId
};
treeSelectData.value = Tool.copy(docTree.value);
// 为选择树添加一个"无"
treeSelectData.value.unshift({id: 0, name: '无'});
setTimeout(function () {
if (editor == null) {
createEditor();
}else {
editor.destroy();//这里做了一次判断,判断编辑器是否被创建,如果创建了就先销毁。
createEditor();
}
})
}
亲测,目前没报错,报错了再说 哈哈哈~
写回答
3回答
-
慕粉174719507
2022-03-13
安装wangeditor的时候与课程的版本一致就没这么多问题了 npm i wangeditor@4.6.3 --save
212022-05-29 -
蜗牛快跑__
2022-03-31
请问下,hljs 是什么?
00 -
甲蛙
2022-01-21
点赞!点赞!
00
相似问题