From 4b668cf18649ef678d6e6e84a4210731f5a9cb39 Mon Sep 17 00:00:00 2001 From: 670788339 <670788339@qq.com> Date: Sun, 2 Nov 2025 17:27:51 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Course/courseTag.vue | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/components/Course/courseTag.vue b/src/components/Course/courseTag.vue index a6c9860e..4dbf27ff 100644 --- a/src/components/Course/courseTag.vue +++ b/src/components/Course/courseTag.vue @@ -153,13 +153,7 @@ export default { handleTagRemove(tagId) { this.selectedTags = this.selectedTags.filter(id => id !== tagId) this.$emit('change', this.displayTags) - // 清空输入框内容 - if (this.$refs.tagSelect) { - const input = this.$refs.tagSelect.$refs.input - if (input) { - input.value = '' - } - } + this.clearInput(); }, removeTag(tagId) { this.handleTagRemove(tagId) @@ -186,12 +180,12 @@ export default { } if (!this.searchResults.length && inputVal && this.selectedTags.length < this.maxTags) { this.createNewTag(event.target.value.trim()) - event.target.value = '' + this.clearInput(); } else if (this.selectedTags.length >= this.maxTags) { this.$message.warning('最多只能添加5个标签') - event.target.value = '' + this.clearInput(); } else { - event.target.value = '' + this.clearInput(); } }, @@ -209,10 +203,16 @@ export default { this.previousTags = [...newValues]; this.$emit('change', this.displayTags); + this.clearInput(); + }, + + clearInput() { if (this.$refs.tagSelect) { const input = this.$refs.tagSelect.$refs.input; if (input) { input.value = ''; + // 触发input事件确保组件状态更新 + input.dispatchEvent(new Event('input')); } } },