Vue wangEditor报错 Cannot set property ‘uploadImgShowBase64‘ of undefined“方法
Vue wangEditor报错 Cannot set property 'uploadImgShowBase64' of undefined"方法由于npm install了最新版本的wangEditor 复制其他博主封装的富文本 展示总是报错 东西也不写全。后来在 thinkplayer的文章里 后知后觉发现问题原因。注意看代码第三行 由于更新了版本 老的customConfig 变成了con
·
由于npm install了最新版本的wangEditor 复制其他博主封装的富文本 展示总是报错 东西也不写全。后来在 thinkplayer的文章里 后知后觉发现问题原因。
注意看代码第三行 由于更新了版本 老的customConfig 变成了config。 打印下可以看到, 可以用thinkplaer博主的三元 也可以把this.editor.customConfig 全部替换成 this.editor.config就能正常运行了
this.editor = new E(this.$refs.toolbar, this.$refs.editor)
console.log(this.editor)
this.editor.customConfig = this.editor.customConfig ? this.editor.customConfig : this.editor.config
this.editor.customConfig.uploadImgShowBase64 = false // base 64 存储图片
this.editor.customConfig.uploadImgServer = ''// 填写配置服务器端地址
this.editor.customConfig.uploadImgHeaders = { }// 自定义 header
this.editor.customConfig.uploadFileName = 'file' // 后端接受上传文件的参数名
this.editor.customConfig.uploadImgParams = {
// 如果版本 <=v3.1.0 ,属性值会自动进行 encode ,此处无需 encode
// 如果版本 >=v3.1.1 ,属性值不会自动 encode ,如有需要自己手动 encode
file_type: 'img'
}
this.editor.customConfig.uploadImgMaxSize = 2 * 1024 * 1024 // 将图片大小限制为 2M
this.editor.customConfig.uploadImgMaxLength = 6 // 限制一次最多上传 6 张图片
this.editor.customConfig.uploadImgTimeout = 3 * 60 * 1000 // 设置超时时间
更多推荐
已为社区贡献1条内容
所有评论(0)