内心油腻
内心油腻
  • 发布:2020-07-10 14:36
  • 更新:2020-07-11 14:14
  • 阅读:743

【报Bug】内层v-for不受上层v-if条件控制

分类:uni-app

产品分类: uniapp/小程序/微信

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: win 10

HBuilderX类型: 正式

HBuilderX版本号: 2.7.14

第三方开发者工具版本号: 1.02.1910120

基础库版本号: 2.12.0

项目创建方式: HBuilderX

示例代码:
<template>  
    <view>  
        <view>Test</view>  
        <template v-if="nextStepLength&&nextStep[nextStepIndex].operator">  
            <view v-for="(item,index) in nextStep[nextStepIndex].operator" :key="index" :class="{active:nextStepUserIndexs.includes(index)}">  
                {{index}}  
            </view>  
        </template>  
    </view>  
</template>  

<script>  
    export default {  
        name: 'test',  
        data() {  
            return {  
                nextStepIndex: 0,  
                nextStepUserIndexs: [0],  
                nextStep: [] // nextStep: [ {operator: []} ]  
            }  
        },  
        computed: {  
            nextStepLength () {  
                return this.nextStep.length;   
            }  
        }  
    }  
</script>

操作步骤:

运行以上代码即可

预期结果:

不应该报错

实际结果:

报错了

bug描述:

内层v-for如果绑定:class,会不受上层v-if条件控制,控制台报错,只测试了微信小程序,其他没测试

2020-07-10 14:36 负责人:无 分享
已邀请:
6***@qq.com

6***@qq.com

改成 v-if="nextStepLength>0&&nextStep[nextStepIndex].operator"

  • 内心油腻 (作者)

    测试了没有效果

    2020-07-10 15:00

新为向前

新为向前 - 新为向前

把内部的template换掉试试

  • 内心油腻 (作者)

    template换成view也是没有效果的,但是删除:class就不会报错

    2020-07-10 16:07

内心油腻

内心油腻 (作者)

大家有什么好建议吗

chualosue

chualosue

如果是删除:class就不会报错的话,用三目运算如果空就class为“”试试?

该问题目前已经被锁定, 无法添加新回复