Поскольку я обновляю версию wangEditor с 3.1.1 до 4.7.10, мое приложение не может загрузить редактор с ошибкой в смонтированном хуке. Детали как показано на скриншоте.
Очевидно, ошибка вызвана совместимостью разных версий. Чтобы исправить эту ошибку, нам нужно добавить эту строку кода, чтобы сделать ее совместимой со старыми версиями:
editor.customConfig = editor.customConfig ? editor.customConfig : editor.config
Фрагмент кода:
mounted() {
const _this = this
const editor = new E(this.$refs.editor)
// 选择语言
editor.config.lang = 'en'
// 引入 i18next 插件
editor.i18next = window.i18next
editor.customConfig = editor.customConfig ? editor.customConfig : editor.config
// 自定义菜单配置
editor.customConfig.zIndex = 10
// 文件上传
editor.customConfig.customUploadImg = function(files, insert) {
// files 是 input 中选中的文件列表
// insert 是获取图片 url 后,插入到编辑器的方法
files.forEach(image => {
files.forEach(image => {
upload(_this.imagesUploadApi, image).then(data => {
insert(data.data.url)
})
})
})
}
editor.customConfig.onchange = (html) => {
this.form.content = html
}
editor.create()
}
Ошибка исправлена.