<template v-for="(item, index) in 1" :key="index">
<view v-if="ifShow('v-if', item, index)">{{ item }}</view>
<view v-show="ifShow('v-show', item, index)">{{ item }}</view>
</template>
function ifShow(type: string, item: number, index: string): boolean {
console.log('ifShow', type, item, index);
return false;
}

JQ0 (作者)
item是1,v-for="(item, index) in 1" 循环只执行一次才对,index也只打印了0,实际ifShow方法被执行了两次。换成v-show,ifShow就只执行一次
2025-12-01 11:02