<view class="floor-list">
<view
class="floor-item"
v-for="item in floorList"
:key="item.floor_title.name">
<image
class="floor-title"
:src="item.floor_title.image_src">image>
<view class="floor-img-box">
<view class="right-img-box">
<image
:src="item.product_list[0].image_src"
:style="{ width: item.product_list[0].image_width + 'rpx' }"
mode="widthFix">view>
<view class="left-img-box">
<image
v-for="(item2, i) in item.product_list"
:key="item2.name"
v-if="i !== 0"
:src="item2.image_src"
:style="{ width: item2.image_width + 'rpx' }"
mode="widthFix">image>
view>
view>
view>
view>
不显示第一个对数组slice截取需要的数据进行遍历
<image v-for="(item2, i) in item.product_list.slice(1)"
:key="item2.name"
:src="item2.image_src"
:style="{ width: item2.image_width + 'rpx' }"
mode="widthFix"></image>
vue3中,v-if优先级是高于v-for的,所以执行v-if时,i变量还未定义。在vue2和vue3开发过程中,都不推荐在同一节点上同时使用v-for和v-if的,希望能对你有所帮助。
您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!