Vue子组件代码如下:

 

2. vue使用v-for报错 Elements in iteration expect to have 'v-bind:key' directives

2. vue使用v-for报错 Elements in iteration expect to have 'v-bind:key' directives

 

服务启动之后,浏览器打开,报错如下:

2. vue使用v-for报错 Elements in iteration expect to have 'v-bind:key' directives

 

原因是:

       Vue 2.2.0+的版本里,当在组件中使用v-for时,key是必须的

 

解决办法:

       在v-for 后添加 :key='project'


        2. vue使用v-for报错 Elements in iteration expect to have 'v-bind:key' directives

相关文章: