代码报红对于追求优美代码的强迫症患者来说看着很不舒服, 报红如下:
控制台中也会有:
(Emitted value instead of an instance of Error) <Option v-for="item in searchTypeList">: component lists rendered with v-for should have explicit keys. See https://vuejs.org/guide/list.html#key for more info.
这样的提示, 解决这个报红的问题, 我们要根据他的提示, 循环的时候加入一个唯一的 key, 这里选择使用 index:
- <ul
- class="clearfix course-list">
- <li
- class="left"
- v-for="(item,index)
- in gradeClassfy.primary.grade":key="index"><a
- href="#" rel="external nofollow" >{{item.name}}</a></li>
- </ul>
如此, 报红消失
来源: http://www.jb51.net/article/135829.htm