Vue wangEditor报错 Cannot set property ‘uploadImgShowBase64‘ of undefined“方法

Vue wangEditor报错 Cannot set property 'uploadImgShowBase64' of undefined"方法

由于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 // 设置超时时间
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值