diff --git a/src/components/Course/courseForm.vue b/src/components/Course/courseForm.vue index b473899d..afcaf553 100644 --- a/src/components/Course/courseForm.vue +++ b/src/components/Course/courseForm.vue @@ -607,6 +607,27 @@ export default { // 限制最多5个标签 if (tags.length > 5) { this.$message.warning('最多只能选择5个标签') + // 只保留前5个标签 + const limitedTags = tags.slice(0, 5) + // 更新标签显示 + let ids = ""; + limitedTags.forEach(tag => { + console.log("父组件name : ", tag.tagName) + ids += tag.id + ','; + }) + this.courseInfo.tags = ids; + console.log("父组件ids : ", this.courseInfo.tags) + + // 更新showTags,确保显示与实际数据一致 + this.showTags = limitedTags.map(tag => tag.tagName); + + // 重要:返回截断后的标签数组,确保子组件也同步更新 + this.$nextTick(() => { + if (this.$refs.courseTag) { + // 通知子组件同步标签状态 + this.$refs.courseTag.syncTags(limitedTags); + } + }); return } let ids = ""; diff --git a/src/views/portal/course/Index.vue b/src/views/portal/course/Index.vue index 954c7d62..1b0f3083 100644 --- a/src/views/portal/course/Index.vue +++ b/src/views/portal/course/Index.vue @@ -2694,7 +2694,7 @@ a.custom2 { gap: 15px; align-items: center; padding-top: 2px; - margin-left: 90px; /* 为"热点标签:"文本留出空间 */ + //margin-left: 90px; /* 为"热点标签:"文本留出空间 */ } /* 调整option-item样式以适应换行布局 */