hookehuyr

fix(material-list): 修复切换标签时列表渲染异常问题

通过添加 v-if 和 key 强制重新渲染列表,避免切换标签时 Vue 复用组件导致的显示异常
......@@ -38,7 +38,11 @@
</nut-tabs>
<!-- 列表容器(独立于 nut-tab-pane) -->
<view class="flex-1 min-h-0 overflow-y-auto px-[32rpx] pb-[calc(160rpx+env(safe-area-inset-bottom))] box-border">
<view
v-if="listVisible"
:key="listRenderKey"
class="flex-1 min-h-0 overflow-y-auto px-[32rpx] pb-[calc(160rpx+env(safe-area-inset-bottom))] box-border"
>
<view class="flex flex-col gap-[24rpx]">
<view v-for="(item, index) in currentList" :key="index"
class="material-item bg-white rounded-[24rpx] p-[24rpx] shadow-sm transition-all duration-200 border border-gray-50 flex flex-row"
......@@ -95,7 +99,7 @@
</template>
<script setup>
import { ref, computed } from 'vue'
import { ref, computed, nextTick } from 'vue'
import { useLoad } from '@tarojs/taro'
import NavHeader from '@/components/NavHeader.vue'
import SearchBar from '@/components/SearchBar.vue'
......@@ -106,6 +110,8 @@ import Taro from '@tarojs/taro'
const searchValue = ref('')
const activeTabId = ref('')
const listVisible = ref(true)
const listRenderKey = ref(0)
/**
* 页面标题
......@@ -353,6 +359,11 @@ useLoad((options) => {
*/
const onTabClick = (id) => {
activeTabId.value = id
listVisible.value = false
nextTick(() => {
listRenderKey.value += 1
listVisible.value = true
})
// 可以在这里触发加载逻辑
// loadMaterialsByCategory(id)
}
......