1、这是什么警告
- 原由:uniapp的v-for的写法导致的
- 该提示是性能优化的提示,并不影响程序的正常运行(在微信小程序中运行时出现的)
2、如何消除该提示
- v-for搭配key使用
- 在:for后面添加:key=“key” 可消除警告。
3、实例
使用前:
<swiper-item v-for="(item,key) in swipers">
<view class="swiper-item">
<image :src="item" mode="aspectFill"></image>
</view>
</swiper-item>
使用后:
<swiper-item v-for="(item,key) in swipers" :key="key">
<view class="swiper-item">
<image :src="item" mode="aspectFill"></image>
</view>
</swiper-item>