将 v-for 写在 template上时,template上不能使用key,
但 v-for 必须要指定key,所以循环遍历的元素上,需要加上key
(key是唯一标识,不允许重复)
同一标签上,不能同时使用v-for和v-if,怎么办?
<ul>
<template v-for="(item,index) in ['国庆节', '春节', '元旦']">
<li v-if="item !== '春节'" :key="index">{{item}}</li>
</template>
</ul>