1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > wangeditor富文本编辑器的复制word到浏览器发生乱码

wangeditor富文本编辑器的复制word到浏览器发生乱码

时间:2022-05-19 05:59:45

相关推荐

wangeditor富文本编辑器的复制word到浏览器发生乱码

wangeditor富文本编辑器的复制word到浏览器发生乱码

使用编辑器出现复制word里文本,会携带style样式到浏览器中出现乱码

展示的效果并不是想要的

通过添加

editor.customConfig.pasteFilterStyle = false; //手动关闭掉粘贴样式的过滤

就可以完美解决此问题

若出现报错property 'pasteFilterStyle' of undefined

则可以通过重新安装wangeditor解决问题

npm install wangeditor

另附我的封装代码

<template ><div><div ref="editor" class="editor"></div></div></template><script>import E from "wangeditor";export default {name: "editor",data() {return {currentValue: this.value};},model: {prop: 'value',event: 'change'},props: {value: {type: String,default:''}},methods: {},watch: {value: function(val, oval) {this.currentValue = val;this.editor.txt.html(this.currentValue);}},mounted() {var editor = new E(this.$refs.editor);this.editor = editor;editor.customConfig.uploadImgShowBase64 = false;editor.customConfig.uploadImgServer =process.env.VUE_APP_BACKEND_URL_PROXY + "/file/upload";editor.customConfig.uploadImgHeaders = {}; // 自定义 headereditor.customConfig.uploadFileName = "filedata";editor.customConfig.uploadImgMaxSize = 5 * 1024 * 1024;editor.customConfig.uploadImgMaxLength = 6;editor.customConfig.uploadImgTimeout = 3 * 60 * 1000;editor.customConfig.pasteFilterStyle = false; //手动关闭掉粘贴样式的过滤// 配置菜单editor.customConfig.menus = ["head", // 标题"bold", // 粗体"fontSize", // 字号"fontName", // 字体"italic", // 斜体"underline", // 下划线"strikeThrough", // 删除线"foreColor", // 文字颜色"backColor", // 背景颜色"link", // 插入链接"list", // 列表"justify", // 对齐方式"quote", // 引用//"emoticon", // 表情"image", // 插入图片//"table", // 表格//"video", // 插入视频//"code", // 插入代码"undo", // 撤销"redo", // 重复"fullscreen" // 全屏];editor.customConfig.uploadImgHooks = {fail: (xhr, editor, result) => {// 插入图片失败回调},success: (xhr, editor, result) => {// 图片上传成功回调},timeout: (xhr, editor) => {// 网络超时的回调},error: (xhr, editor) => {// 图片上传错误的回调},customInsert: (insertImg, result, editor) => {// 图片上传成功,插入图片的回调const url =this.__ftpPath +result.data.filePath;insertImg(url);}};editor.customConfig.onchange = html => {this.currentValue = html;this.$emit("change", html); // 将内容同步到父组件中};editor.customConfig.customAlert = info => {this.$message.error(info);};editor.create();this.editor.txt.html(this.currentValue);}};</script><style>.editor {width: 100%;height: 100%;margin: 0 auto;position: relative;z-index: 0;}.w-e-text-container{height: 95%!important;}</style>

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