秦佳浩 2 months ago
commit 090b6fcf85

@ -41,34 +41,36 @@
</view> </view>
</view> </view>
<!-- 子分类 --> <!-- 子分类 -->
<!-- 这是一个条件渲染的视图元素只有当subCategoryList数组的长度大于0时才会显示 -->
<view v-if="subCategoryList.length" <view v-if="subCategoryList.length"
class="th-cate-con"> class="th-cate-con">
<!-- 使用v-for指令循环遍历subCategoryList数组index为当前项的索引thCateItem代表数组中的每个子分类项对象 -->
<block v-for="(thCateItem, index) in subCategoryList" <block v-for="(thCateItem, index) in subCategoryList"
:key="index"> :key="index">
<!-- 每个子分类的外层视图容器用于包裹子分类相关的内容设置了类名为sub-category -->
<view class="sub-category"> <view class="sub-category">
<!-- 子分类具体项的视图容器绑定了点击事件toCatePage并且通过自定义属性传递了子分类相关的ID信息 -->
<view class="sub-category-item" <view class="sub-category-item"
:data-categoryid="thCateItem.categoryId" :data-categoryid="thCateItem.categoryId"
:data-parentid="thCateItem.parentId" :data-parentid="thCateItem.parentId"
@tap="toCatePage"> @tap="toCatePage">
<!-- 展示子分类对应的图片通过util.checkFileUrl方法对图片路径进行处理可能是检查路径合法性添加域名等操作并设置了类名为more-pic以及图片的显示模式为widthFixwidthFix模式可以让图片宽度自适应容器宽度高度按比例缩放 -->
<image :src="util.checkFileUrl(thCateItem.pic)" <image :src="util.checkFileUrl(thCateItem.pic)"
class="more-pic" class="more-pic"
mode="widthFix" /> mode="widthFix" />
<!-- 展示子分类的名称通过双括号插值表达式绑定子分类项对象中的categoryName属性来显示具体的名称文本 -->
<text>{{ thCateItem.categoryName }}</text> <text>{{ thCateItem.categoryName }}</text>
</view> </view>
</view> </view>
</block> </block>
</view> </view>
<!-- 当subCategoryList数组长度为0时显示这个视图元素用于给用户提示当前分类下暂无子分类的信息 -->
<view v-else <view v-else
class="cont-item empty"> class="cont-item empty">
该分类下暂无子分类~ 该分类下暂无子分类~
</view> </view>
</scroll-view>
<!-- 右侧内容end -->
</view>
</view>
</template>
<script setup> <script setup>
import util from '@/utils/util.js' import util from '@/utils/util.js'
import { ref, onLoad } from 'vue' import { ref, onLoad } from 'vue'
import { uni } from '@dcloudio/uni-app' import { uni } from '@dcloudio/uni-app'
@ -142,8 +144,8 @@
}) })
} }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@import "./category.scss"; @import "./category.scss";
</style> </style>

Loading…
Cancel
Save