vue报错信息(Avoid using non-primitive value as key, use stringnumber value instead.)
避免使用非原始值作为关键字,而使用字符串/数字值代替。
解决方法:
<el-carousel class="swiper-container" :interval="5000" arrow="hover" @change="carouselItem">
<el-carousel-item v-for="item in photoList" :key="item">
<div class="swiper-slide">
<div class="swiper" v-for="index in item">
<a @click='goTo(2)' ><img :src="index" /></a>
</div>
</div>
</el-carousel-item>
</el-carousel>
for循环中,绑定的key值不能为对象,而是取一个字符串或数值,如下图:
<el-carousel class="swiper-container" :interval="5000" arrow="hover" @change="carouselItem">
<el-carousel-item v-for="item in photoList" :key="item.id">
<div class="swiper-slide">
<div class="swiper" v-for="index in item">
<a @click='goTo(2)' ><img :src="index" /></a>
</div>
</div>
</el-carousel-item>
</el-carousel>
本文来自博客园,作者:小基狠努力啊,转载请注明原文链接:https://www.cnblogs.com/ylh188/p/14983886.html