diff --git a/src/pages/concept/components/CustomView.vue b/src/pages/concept/components/CustomView.vue index 5bbebb5..9d3d8c3 100644 --- a/src/pages/concept/components/CustomView.vue +++ b/src/pages/concept/components/CustomView.vue @@ -40,7 +40,7 @@ - {{ item.name.split('-')[1] }} + {{ item.name.split("-")[1] }} @@ -61,7 +61,7 @@ :class="['industry-item', { active: isSelected(item.content) }]" @click="handleAddTag(item.content)" > - {{ item.content.split('-')[1] }} + {{ item.content.split("-")[1] }} @@ -106,16 +106,29 @@ const handleBack = () => { }; const myTagList = ref([]); +const industryList = ref([]); const page = ref(0); -const industryList = computed(() => { - const arr = [...props.allTagList] - return arr.splice(page.value, 10); -}); + +const getTagList = () => { + return [...props.allTagList].splice(page.value, 10); +}; const handleChange = () => { - page.value = page.value ? 0 : 10 -} + page.value = page.value ? 0 : 10; + industryList.value = getTagList(); +}; +watch( + () => props.allTagList, + (newVal) => { + if (newVal && newVal.length > 0) { + industryList.value = getTagList(); + } + }, + { + immediate: true, + }, +); // 是否选中 function isSelected(tag) { diff --git a/src/pages/industry/components/CustomView.vue b/src/pages/industry/components/CustomView.vue index 8968266..574e8b3 100644 --- a/src/pages/industry/components/CustomView.vue +++ b/src/pages/industry/components/CustomView.vue @@ -106,15 +106,29 @@ const handleBack = () => { }; const myTagList = ref([]); -const page = ref(0); -const industryList = computed(() => { - const arr = [...props.allTagList] - return arr.splice(page.value, 10); -}); +const industryList = ref([]); +const page = ref(0) + +const getTagList = () => { + return [...props.allTagList].splice(page.value, 10); +}; const handleChange = () => { - page.value = page.value ? 0 : 10 -} + page.value = page.value ? 0 : 10; + industryList.value = getTagList(); +}; + +watch( + () => props.allTagList, + (newVal) => { + if (newVal && newVal.length > 0) { + industryList.value = getTagList(); + } + }, + { + immediate: true, + }, +); // 是否选中 function isSelected(tag) {