feat: 优化行业组件标签列表的获取逻辑,添加响应式更新
This commit is contained in:
parent
f80e614a15
commit
a7a3a08ee3
|
|
@ -40,7 +40,7 @@
|
|||
</view>
|
||||
<view class="my-industry-list" v-if="myTagList.length > 0">
|
||||
<view class="industry-item" v-for="(item, index) in myTagList">
|
||||
<view class="industry-name">{{ item.name.split('-')[1] }}</view>
|
||||
<view class="industry-name">{{ item.name.split("-")[1] }}</view>
|
||||
<view class="industry-btn" @click="handleDeleteTag(index)"></view>
|
||||
</view>
|
||||
</view>
|
||||
|
|
@ -61,7 +61,7 @@
|
|||
:class="['industry-item', { active: isSelected(item.content) }]"
|
||||
@click="handleAddTag(item.content)"
|
||||
>
|
||||
<view class="industry-name">{{ item.content.split('-')[1] }}</view>
|
||||
<view class="industry-name">{{ item.content.split("-")[1] }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-else class="no-data"> <u-empty /></view>
|
||||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue