小程序商品列表布局(存在二级联动)

 

二级联动需要找区分每组数据的特殊的值。利用每组数据的下标,通过计算属性computed:{  },创建cateObj对象

computed:{//计算属性
			cateObj(){//二级联动,通过下标寻找相应数据
				console.log(this.categoryDatas[this.navIndex]);//输出数据,用来测试取数据是否成功,方便查找数据
				return this.categoryDatas[this.navIndex] //navIndex是点谁谁高亮的标记等于下标
			}
		},
mounted() {
			this.getCategory();
		},
methods:{
			async getCategory(){
				const res= await request('/getCategoryDatas');
				console.log(res);
				this.categoryDatas=res.categoryDatas;
			},
			//点击切换下标
			changeNavIndex(index){
				this.navIndex = index;
			}
		}
<view class="right">
				<scroll-view class="categoryScroll" scroll-y="true" >
					<!-- 大图 -->
					<image class="cateImg" :src="cateObj.imgUrl" mode=""></image>
					<!-- 列表 -->
					<view class="goodsList">
						<view class="goodsItem" v-for="item in cateObj.subCateList" :key="iem.id">
							<image class="goodsImg" :src="item.wapBannerUrl" mode=""></image>
							<view class="goodsName">
								{{item.name}}
							</view>
						</view>
					</view>
				</scroll-view>
			</view>

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值