一汀烟雨
一汀烟雨
  • 发布:2019-12-20 14:39
  • 更新:2019-12-20 14:39
  • 阅读:1497

【报Bug】三元表达式出现在v-for表达式中报错

分类:uni-app

详细问题描述

[内容]

当使用v-for语句的时候,循环体是对象时候取值会报错

重现步骤

[步骤]
看代码清楚一些,item是循环项,当用item做三元运算时会报错

<div v-for="(item, index) in items" :key="item.id">  
            <h3 class="title_h3 d-box">  
                <div class="flex-auto">账户{{ index + 1 }}</div>  
                <uni-icons @click="removeAcc(item, index)" type="trash" color="red" size="20"></uni-icons>  
            </h3>                     
            <cmd-cell-item :title="(item ? item.account_name: '') + '(尾号:' + ( (item ? item.account_number: '') + '').substr(-4) + ')'" @click="to('/pages/account/edit?index=' + index)"  
             :brief="(item ? item.opening_bank: '')" arrow />  
        </div>

[结果]

[Vue warn]: Property or method "item" 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.

[期望]

修复

IDE运行环境说明

[HBuilder 或 HBuilderX。如果你用其他工具开发uni-app,也需要在此说明]

[IDE版本号]

2.4.6.20191210

[windows版本号]
win10

[mac版本号]

uni-app运行环境说明

[运行端是h5或app或某个小程序?]

app端存在,H5不存在

[运行端版本号]

[项目是cli创建的还是HBuilderX创建的?如果是cli创建的,请更新到最新版cli再试]

[编译模式是老模板模式还是新的自定义组件模式?]

App运行环境说明

[Android版本号]

[iOS版本号]

[手机型号]

[模拟器型号]

附件

[IDE问题请提供HBuilderX运行日志。菜单帮助-查看运行日志,点右键打开文件所在目录,将log文件压缩成zip包上传]

[App问题请提供可重现问题的代码片段,你补充的细一点,问题就解决的快一点]

[App安装包或H5地址]

[可重现代码片段]

联系方式

[QQ]

2019-12-20 14:39 负责人:无 分享
已邀请:

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