v-for循环数据,展示指定数量的数据
示例图片:
代码:
<view class="shopinfo" v-for="(item,index) in order" :key = "index">
<view class="shopinfo_img">
<image :src="item.img_url" mode=""></image>
</view>
<view class="shopinfo_tip">
<view class="shopinfo_tip_left">
<view class="shop_name">
<view class="shop_name_1">{{item.goods_name}}</view>
</view>
<view class="shop_num">×{{item.item_quantity}}</view>
</view>
<view class="shopinfo_tip_right">¥{{item.item_price}} </view>
</view>
</view>
如果只想展示诸多数据中的前两条数据,则在v-for="(item,index) in order"
的渲染数组后面添加v-for="(item,index) in order.slice(0,2)"
,截取order数组的前两个,就可以实现了