怎么限制只渲染2条数据呢?
- <ul>
- <li v-for="i in list" v-text="i"></li>
- </ul>
-
- list: ['a','b','c','d']
解决方案1:
- <ul>
- <li v-for="i in list.slice(0, 2)" v-text="i"></li>
- </ul>
解决方案2:
- <ul>
- <li v-for="(i, index) in list" v-if="index < 2" v-text="i"></li>
- </ul>