错误集

CKEDITOR setData 失败: 'getSelection' of undefined

环境:vue,element ui dialog

现象:第一次setData成功,第二次的时候提示 'getSelection' of undefined(第二次是指dialog关闭后再次打开)

原因:可能是由于dialog关闭后,会把dialog中的ckeditor中嵌套的iframe移除(不确定)

解决:

先销毁,再创建

if(CKEDITOR.instances["abc"]) CKEDITOR.instances["abc"].destroy();
CKEDITOR.replace('abc',{
   removeButtons: removeButtons
});
CKEDITOR.instances["abc"].setData('插入的内容');