diff --git a/src/components/wangEditor/index.vue b/src/components/wangEditor/index.vue index 5a3ebad..cb0f6e4 100644 --- a/src/components/wangEditor/index.vue +++ b/src/components/wangEditor/index.vue @@ -109,8 +109,10 @@ export default { }, methods: { handleCreated(editor) { + // ✅ 关键修复:判断 editor 是否存在,防止组件销毁后回调拿到undefined + if (!editor) return this.editor = editor - editor.config.height = this.height + // editor.config.height = this.height }, handleChange(editor) { this.$emit('change', editor.getHtml()) diff --git a/src/views/weChatMiniProgram/activity.vue b/src/views/weChatMiniProgram/activity.vue index 588f4cb..5cf84bf 100644 --- a/src/views/weChatMiniProgram/activity.vue +++ b/src/views/weChatMiniProgram/activity.vue @@ -95,11 +95,11 @@ + @@ -276,7 +276,7 @@ export default { { key: -1, display_name: '已取消' } ], imageUrl: require('@/assets/images/system/default-img.jpg'), - editorRef: 'test', + editorRef: null, editorContent: '', cancelDialogVisible: false, cancelForm: { @@ -361,6 +361,9 @@ export default { } }, methods: { + onEditorRef(ref) { + this.editorRef = ref + }, [CRUD.HOOK.beforeRefresh]() { this.crud.params.libcode = this.user.fonds.fondsNo if (this.blurryTime) { @@ -381,12 +384,16 @@ export default { }, // 新增前 [CRUD.HOOK.beforeToAdd]() { - this.editorContent = '' + // this.editorContent = '' }, // 初始化编辑时候 [CRUD.HOOK.beforeToEdit](crud, form) { form.numberLimit = form.activityPeople === 0 ? 1 : 2 - this.editorContent = form.activityContent + this.$nextTick(() => { + if (this.editorRef && form.activityContent) { + this.editorContent = form.activityContent + } + }) }, // 提交前做的操作 [CRUD.HOOK.afterValidateCU](crud) { @@ -425,6 +432,7 @@ export default { if (!isImage) { this.$message({ message: '只可上传图片', type: 'error', offset: 8 }) } + const isLt2M = file.size / 1024 / 1024 < 2 if (!isLt2M) { this.$message({ message: '图片大小不能超过2MB', type: 'error', offset: 8 }) @@ -432,7 +440,7 @@ export default { return isImage && isLt2M }, contentData(val) { - console.log('contentData', val) + // console.log('contentData', val) this.editorContent = val }, getStatusText(status) {