Vue学习陷阱
v-for在嵌套时index没办法重复用,内循环与外循环不能共用一个index <swiper-item v-for="(items,index) in swiperList" :key="index"> <div v-for="item in items" class="swiper-info" :key="item.id" @click="choose" > <image :src="item.url" class="swiper-image" :style="styleObject"/> </div> </swiper-item> 解决办法:给内循环再加上另一个索引 <swiper-item v-for="(items,index) in swiperList" :key="index"> <div v-for="(item,i) in items" class="swiper-info" :key="i" @click="choose" > <image :src="item.url" class="swiper-image" :style="styleObject"/> </div> </swiper-item>
不忘初心,不负梦想