1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > vue使用wangEditor富文本光标乱飘

vue使用wangEditor富文本光标乱飘

时间:2021-05-06 12:12:24

相关推荐

vue使用wangEditor富文本光标乱飘

记录下:vue使用wangEditor封装了个富文本编辑器编辑时光标老乱飘

解决方案:

光标乱飘可以在watch监听文本内容实时更新时,在输入文本的时候让监听无效。

data() {return {editor: null,editorContent: null,isChange: false,// 加个判断值};},watch: {// isChange 监听实时更新,判断输入文本时让监听无效value(val) {if (!this.isChange) {this.editorContent = val;this.editor.txt.html(val);}this.isChange = false;},initEditor() {this.editor = new WEditor(this.$refs.editor);this.editor.config.menus = ['head','bold','fontSize','fontName','italic','strikeThrough','justify','quote','undo','redo',];this.editor.config.customUploadImg = (resultFiles, insertImgFn) => {const formData = new FormData();resultFiles.forEach((item) => {formData.append('file', item);});uploadImage(formData).then((data) => {console.log(data);insertImgFn(data);});};this.editor.config.onchange = (html) => {// 这儿得赋值让离开编辑后状态又生效this.isChange = true;this.editorContent = html;this.$emit('change', this.editorContent);};this.editor.config.zIndex = 2;this.editor.create();},

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。