uniapp 遍历无法读取index

无法读取index
<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>

img


源码地址
https://gitee.com/sachin-ye/uni-app-ts

不显示第一个对数组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的,希望能对你有所帮助。

您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!
PS:问答VIP年卡 【限时加赠:IT技术图书免费领】,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632