Elements in iteration expect to have 'v-bind:key' directives

https://github.com/vuejs/vetur/issues/858

vuejs v-for add bootstrap row every 5 items

<script src="https://vuejs.org/js/vue.min.js"></script>
<div id="demo">
  <div class="row" v-for="i in Math.ceil(items.length / 5)">
    <span v-for="item in items.slice((i - 1) * 5, i * 5)">
  {{item}}
</span>
  </div>
</div>

这段代码会有提示错误,

但是在jsfiddle里面,可以正常运行 https://jsfiddle.net/ud25tGNwMddCP7JI/jc1u78r0/1/

  <div class="row" v-for="i in Math.ceil(formDetail.OptionalFields.length / 2)" v-bind:key="i">
            <span v-for="(item,index) in formDetail.OptionalFields.slice((i - 1) * 5, i * 5)" :key="index">
              {{item}}
            </span>
          </div>
原文地址:https://www.cnblogs.com/chucklu/p/14207283.html