@@ -2,7 +2,7 @@
|
||||
<!-- 右侧商品列表区 - 上方子分类 + 下方滚动商品网格 -->
|
||||
<view class="right-content">
|
||||
<!-- 子分类(顶部条件) - Figma 1519:250 -->
|
||||
<view class="sub-categories" v-if="subCategories.length > 0">
|
||||
<view class="sub-categories" id="subCategories" v-if="subCategories.length > 0">
|
||||
<view
|
||||
class="sub-cat-item"
|
||||
:class="{ active: activeSubId === item.id }"
|
||||
@@ -12,8 +12,16 @@
|
||||
>{{ item.name }}</view>
|
||||
</view>
|
||||
|
||||
<!-- 商品网格滚动区 -->
|
||||
<scroll-view scroll-y class="product-scroll" :lower-threshold="100" :scroll-top="scrollTopVal" :scroll-with-animation="false" @scrolltolower="onScrollToLower">
|
||||
<!-- 商品网格滚动区 - 固定高度(由父组件动态计算传入),符合官方文档要求 -->
|
||||
<scroll-view
|
||||
scroll-y
|
||||
class="product-scroll"
|
||||
:lower-threshold="100"
|
||||
:scroll-top="scrollTopVal"
|
||||
:scroll-with-animation="false"
|
||||
:style="{ height: scrollHeight + 'px' }"
|
||||
@scrolltolower="onScrollToLower"
|
||||
>
|
||||
<view class="product-grid" v-if="list.length > 0">
|
||||
<view
|
||||
class="product-card"
|
||||
@@ -69,7 +77,9 @@ export default {
|
||||
activeSubId: { type: [String, Number], default: '' },
|
||||
hasMore: { type: Boolean, default: true },
|
||||
loading: { type: Boolean, default: false },
|
||||
scrollTopVal: { type: Number, default: 0 }
|
||||
scrollTopVal: { type: Number, default: 0 },
|
||||
// 商品滚动区固定高度(px),由父组件动态计算传入
|
||||
scrollHeight: { type: Number, default: 400 }
|
||||
},
|
||||
methods: {
|
||||
selectSub(id) { this.$emit('sub-select', id) },
|
||||
@@ -81,15 +91,11 @@ export default {
|
||||
|
||||
<style scoped>
|
||||
/* 右侧内容区 - 上下分:顶部条件 + 下方滚动
|
||||
flex:1 与 height:100% 冲突,二选一(保留 flex:1) */
|
||||
不再依赖 flex:1 撑高度,scroll-view 用父组件传入的固定高度 */
|
||||
.right-content {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: #f2f2f2;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* 顶部子分类条件 - padding 6px 10px 圆角 60px */
|
||||
@@ -116,13 +122,10 @@ export default {
|
||||
color: #ff6800;
|
||||
}
|
||||
|
||||
/* 滚动商品区 - uni-app scroll-view 在 flex 布局里必须同时有 flex:1 + height:0
|
||||
仅 min-height:0 无法让部分端的 scroll-view 正确计算内部 viewport 高度 */
|
||||
/* 滚动商品区 - 高度由父组件通过 :style 传入(px 固定值),
|
||||
符合 uni-app / 微信小程序官方文档「scroll-y 需给固定 height」的要求 */
|
||||
.product-scroll {
|
||||
flex: 1;
|
||||
height: 0;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* 商品网格 - 固定2列 grid,不会因商品个数变化而拉伸占行 */
|
||||
|
||||
Reference in New Issue
Block a user