<view class="product-recommendation-content-title" v-for="(item,index) in circularlist" :key="item.id" @click="crossborderPages(item.productTypeCode)"> <view class="content-img"> <image :src="item.image" mode=""></image> </view> <view class="content-text"> <text class="text1">{{item.name}}</text> <text class="text2">{{item.stock}}粒/{{item.unit}}</text> <text class="text3" v-if="item.activityList && item.activityList[index].perLimit === 1"> <text>¥</text> {{item.activityList[index].buyPrice}} </text> <text class="text3" :class="{ 'text4': item.activityList && item.activityList[index].perLimit === 1 }">¥{{item.price}}</text> <view class="label"> <text v-for="item in 2" :key="item">满5件8折</text> </view> </view> </view>为什么只显示了第一个item.activityList怎么修改
时间: 2023-07-19 16:03:25 浏览: 62
你可以在v-for循环中添加一个嵌套的v-for循环来遍历每个产品的活动列表。例如:
```
<view class="product-recommendation-content-title" v-for="(item,index) in circularlist" :key="item.id" @click="crossborderPages(item.productTypeCode)">
<view class="content-img">
<image :src="item.image" mode=""></image>
</view>
<view class="content-text">
<text class="text1">{{item.name}}</text>
<text class="text2">{{item.stock}}粒/{{item.unit}}</text>
<template v-for="activity in item.activityList">
<text class="text3" v-if="activity.perLimit === 1">
<text>¥</text>{{activity.buyPrice}}
</text>
</template>
<text class="text3" v-if="!item.activityList || item.activityList.length === 0">
¥{{item.price}}
</text>
<template v-for="activity in item.activityList" :key="activity.activityId">
<text class="text3" v-else>
¥{{activity.price}}
</text>
</template>
<view class="label">
<text v-for="item in 2" :key="item">满5件8折</text>
</view>
</view>
</view>
```
这里使用了一个嵌套的v-for循环来遍历每个产品的活动列表。同时,我们还添加了一个条件判断,以便在没有活动列表或活动列表为空时显示原始价格。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)