vue v-for v-if同时使用时候会抛出警告
<ul v-show="showGN" @click="showGN = !showGN">
<li v-if="item.packable == 1" v-for="item in gameNameList" @click="changeGn(item.name, item.id)">{{ item.name }}({{ item.id }})</li>
</ul>
vue.common.js?e881:1137 [Vue warn]:
- : Using v-if and v-for on the same element is not recommended - consider filtering the source Array instead. (found in component:
1.解决方法一
v-if和v-for在一起会报错,建议使用v-show
2.解决方法二
<template v-if="routers[selectedNav].type == 2">
<template v-for="v1 in routers[selectedNav].children">
<h4>{{v1.name}}</h4>
<ul>
<li v-if="v2.show" v-for="v2 in v1.children">
<a href="javascript:void(0)" v-link="{ name: v2.link }">{{v2.name}}</a>
</li>
</ul>
</template>
</template>