<div v-for="(item, index) in cMList" :key=index> …… …… <div v-for="(items, indexs) in item.list" :key=indexs> {{items.content}} //我想只显示前三条数据 </div></div
上面这样可以输出所有的的数据 但是现在我只想让它输出前三条数据 我改成这样了v-for="(items, indexs) in item.list.slice(0, 2)"
但是报错了 TypeError: Cannot read property 'slice' of undefined"
这是为什么?
cMList: [ { uid: 10001, list: [ {nickname: 'aaa', content: '666', time: '2019.2.12'}, {nickname: 'aaa', content: '666', time: '2019.2.12'}, {nickname: 'aaa', content: '666', time: '2019.2.12'}, {nickname: 'aaa', content: '666', time: '2019.2.12'}, {nickname: 'aaa', content: '666', time: '2019.2.12'}, {nickname: 'aaa', content: '666', time: '2019.2.12'}, {nickname: 'aaa', content: '666', time: '2019.2.12'} ] } ]
慕田峪9158850
幕布斯6054654
相关分类