feat: 优化行业组件标签列表的获取逻辑,添加响应式更新
This commit is contained in:
parent
f80e614a15
commit
a7a3a08ee3
|
|
@ -40,7 +40,7 @@
|
||||||
</view>
|
</view>
|
||||||
<view class="my-industry-list" v-if="myTagList.length > 0">
|
<view class="my-industry-list" v-if="myTagList.length > 0">
|
||||||
<view class="industry-item" v-for="(item, index) in myTagList">
|
<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 class="industry-btn" @click="handleDeleteTag(index)"></view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -61,7 +61,7 @@
|
||||||
:class="['industry-item', { active: isSelected(item.content) }]"
|
:class="['industry-item', { active: isSelected(item.content) }]"
|
||||||
@click="handleAddTag(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>
|
</view>
|
||||||
<view v-else class="no-data"> <u-empty /></view>
|
<view v-else class="no-data"> <u-empty /></view>
|
||||||
|
|
@ -106,16 +106,29 @@ const handleBack = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const myTagList = ref([]);
|
const myTagList = ref([]);
|
||||||
|
const industryList = ref([]);
|
||||||
const page = ref(0);
|
const page = ref(0);
|
||||||
const industryList = computed(() => {
|
|
||||||
const arr = [...props.allTagList]
|
const getTagList = () => {
|
||||||
return arr.splice(page.value, 10);
|
return [...props.allTagList].splice(page.value, 10);
|
||||||
});
|
};
|
||||||
|
|
||||||
const handleChange = () => {
|
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) {
|
function isSelected(tag) {
|
||||||
|
|
|
||||||
|
|
@ -106,15 +106,29 @@ const handleBack = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const myTagList = ref([]);
|
const myTagList = ref([]);
|
||||||
const page = ref(0);
|
const industryList = ref([]);
|
||||||
const industryList = computed(() => {
|
const page = ref(0)
|
||||||
const arr = [...props.allTagList]
|
|
||||||
return arr.splice(page.value, 10);
|
const getTagList = () => {
|
||||||
});
|
return [...props.allTagList].splice(page.value, 10);
|
||||||
|
};
|
||||||
|
|
||||||
const handleChange = () => {
|
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) {
|
function isSelected(tag) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue