belowfox
belowfox
  • 发布:2019-07-19 09:06
  • 更新:2019-10-31 17:42
  • 阅读:2912

【报Bug】uni-app: app端,在v-for中使用过滤器报错,环境都是官方最新稳定版

分类:uni-app

问题更新

之前用我自己项目的代码提bug,为了排除干扰,刚刚专门新建了一个demo项目,bug可以重现!
整个demo代码提交到附件了.

demo就这一页代码

<template>  
    <view >  
        <view v-for="eq in equipmentsArr" :key="eq.equipmentSn">  
            <!-- 这句不报错 -->  
            <view>数据:{{ getEquipmentCalcDataBySn[eq.equipmentSn].CompletionRate}}</view>  

            <!-- 这句在h5正常,在app运行就报错!! -->  
            <view>数据:{{ getEquipmentCalcDataBySn[eq.equipmentSn].CompletionRate|number(1)}}</view>  
        </view>  
    </view>  
</template>  

<script>  
    export default {  
        data() {  
            return {  
                equipmentsArr: [{  
                        equipmentSn: 111,  
                    },  
                    {  
                        equipmentSn: 222,  
                    },  
                ],  
                getEquipmentCalcDataBySn: {  
                    111: {  
                        CompletionRate: 0.5,  
                    },  
                    222: {  
                        CompletionRate: 0.7,  
                    },  
                }  

            };  
        },  
        filters: {  
            number() {  
                //1转换成百分比表示  
                if (type == 1) {  
                    return (new Number(arg) * 100).toFixed(1) + '%'  
                } else if (type == 2) {  
                    //2保留小数extra位  
                    return new Number(arg).toFixed(extra)  
                }  

            }  
        }  
    }  
</script>  

<style>  

</style>  

h5上显示正常

app上报错

报错信息

09:58:24.260 [Vue warn]: Property or method "eq" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.  
09:58:24.304 (found in pages/index/index)  
09:58:24.322 TypeError: undefined is not an object (evaluating '_vm.eq.equipmentSn')

原问题

详细问题描述

在v-for中使用过滤器,app端报错,h5端正常.

运行环境

最新2.1.1版hbuilderX, 用hbuilderX创建的项目,新版编译器,"usingComponents" : true,app端安卓官方基座9.5.10版,求官方机器人不要再回复我更新了.

报错的代码:

<template>  
    <view>  
        <view v-for="eq in equipmentsArr" :key="eq.equipmentSn">  
            <uni-card :title="`${$t('sbmc')}:${eq.name}  SN:${eq.equipmentSn}`" :is-full="false" @click="toDetailPage(eq.equipmentSn)">  
                <view class="card-body" hover-class="navigator-hover">  
                    <view class="body-item">{{ $t('dcl') }}:{{ getEquipmentCalcDataBySn[eq.equipmentSn].CompletionRate.v|number(1) }}</view>  
                </view>  
            </uni-card>  
        </view>  
    </view>  
</template>

问题出现在上面的|number(1)过滤器,如果删掉这个过滤器,不报错;加上这个过滤器,h5端正常效果,app端报错,
报错信息:

09:00:11.260 [Vue warn]: Property or method "eq" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.  
09:00:11.301 (found in pages/equipments/list/list)  
09:00:11.322 TypeError: undefined is not an object (evaluating '_vm.eq.equipmentSn')

联系方式

qq 532430012

2019-07-19 09:06 负责人:无 分享
已邀请:
belowfox

belowfox (作者)

没有官方人员看看吗,明显的bug啊,demo即可重现

y***@outlook.com

y***@outlook.com

老哥解决了吗

我遇到 v-if 里面的代码, 只要有过滤器就必执行
没有过滤器的时候就不执行

  • l***@163.com

    我也是, 这个坑踩的好狠, 早知道这么不灵活, 转战原生小程序就好了

    2019-11-01 21:42

  • 1***@qq.com

    回复 l***@163.com: 同是沦落人,h5一切完美,app端想吃翔...

    2019-12-14 17:56

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