mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-07 18:06:44 +08:00
标签清除
This commit is contained in:
@@ -153,13 +153,7 @@ export default {
|
|||||||
handleTagRemove(tagId) {
|
handleTagRemove(tagId) {
|
||||||
this.selectedTags = this.selectedTags.filter(id => id !== tagId)
|
this.selectedTags = this.selectedTags.filter(id => id !== tagId)
|
||||||
this.$emit('change', this.displayTags)
|
this.$emit('change', this.displayTags)
|
||||||
// 清空输入框内容
|
this.clearInput();
|
||||||
if (this.$refs.tagSelect) {
|
|
||||||
const input = this.$refs.tagSelect.$refs.input
|
|
||||||
if (input) {
|
|
||||||
input.value = ''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
removeTag(tagId) {
|
removeTag(tagId) {
|
||||||
this.handleTagRemove(tagId)
|
this.handleTagRemove(tagId)
|
||||||
@@ -186,12 +180,12 @@ export default {
|
|||||||
}
|
}
|
||||||
if (!this.searchResults.length && inputVal && this.selectedTags.length < this.maxTags) {
|
if (!this.searchResults.length && inputVal && this.selectedTags.length < this.maxTags) {
|
||||||
this.createNewTag(event.target.value.trim())
|
this.createNewTag(event.target.value.trim())
|
||||||
event.target.value = ''
|
this.clearInput();
|
||||||
} else if (this.selectedTags.length >= this.maxTags) {
|
} else if (this.selectedTags.length >= this.maxTags) {
|
||||||
this.$message.warning('最多只能添加5个标签')
|
this.$message.warning('最多只能添加5个标签')
|
||||||
event.target.value = ''
|
this.clearInput();
|
||||||
} else {
|
} else {
|
||||||
event.target.value = ''
|
this.clearInput();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -209,6 +203,10 @@ export default {
|
|||||||
this.previousTags = [...newValues];
|
this.previousTags = [...newValues];
|
||||||
this.$emit('change', this.displayTags);
|
this.$emit('change', this.displayTags);
|
||||||
|
|
||||||
|
this.clearInput();
|
||||||
|
},
|
||||||
|
|
||||||
|
clearInput() {
|
||||||
if (this.$refs.tagSelect) {
|
if (this.$refs.tagSelect) {
|
||||||
const input = this.$refs.tagSelect.$refs.input;
|
const input = this.$refs.tagSelect.$refs.input;
|
||||||
if (input) {
|
if (input) {
|
||||||
|
|||||||
Reference in New Issue
Block a user