其他分享
首页 > 其他分享> > Vue报错Custom elements in iteration require 'v-bind:key' directives."错误解决

Vue报错Custom elements in iteration require 'v-bind:key' directives."错误解决

作者:互联网

错误代码

<swiper>
    <swiper-item v-for="item in banners">
      <a :href="item.link">
        <img :src="item.image" alt="">
      </a>
    </swiper-item>
  </swiper>

正确代码

<swiper>
    <swiper-item v-for="(index,item) in banners" :key="index" >
      <a :href="item.link">
        <img :src="item.image" alt="">
      </a>
    </swiper-item>
  </swiper>

标签:Vue,错误代码,bind,require,iteration,报错
来源: https://www.cnblogs.com/leoych/p/15167150.html