4***@qq.com
4***@qq.com
  • 发布:2021-04-08 16:01
  • 更新:2021-08-17 16:59
  • 阅读:642

【报Bug】小程序环境中用v-for渲染的元素,绑定click事件的传参存在bug

分类:uni-app

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

PC开发环境操作系统: Windows

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

HBuilderX类型: 正式

HBuilderX版本号: 3.1.7

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

基础库版本号: *

项目创建方式: HBuilderX

示例代码:

cardList: [
{
menuName: "当日挂号",
path: "/pages/comm/quryOtpHosp"
},
{
menuName: "预约挂号"
},
{
menuName: "预约报到"
},
{
menuName: "门诊缴费"
},
{
menuName: "电子凭条"
},
{
menuName: "缴费记录"
},
{
menuName: "报告查询"
},
{
menuName: "核酸预约"
},
{
menuName: "我的排号"
},
{
menuName: "预约护理"
},
{
menuName: "病案复印"
},
{
menuName: "院内导航"
},
{
menuName: "智能分诊"
},
{
menuName: "医技预约"
},
{
menuName: "住院清单"
},
{
menuName: "住院押金"
},
]

        <!-- #ifdef MP-WEIXIN -->  
        <swiper class="swiper full" indicator-dots="true" interval="3000" duration="500" >  
            <swiper-item v-for="count in (cardList.length / 8)" :key="count" class="box full" >  
                <view class="card box" v-for="(card, index) in cardList.slice(count*8, (count+1)*8)" :key="index" @tap="toMenu(card)">  
                    {{card.menuName}}  
                </view>  
            </swiper-item>  
        </swiper>  
        <!-- #endif -->  

toMenu(card){
console.log(card);
}

操作步骤:

把代码跑起来,点击元素就行

预期结果:

{
menuName: "当日挂号",
path: "/pages/comm/quryOtpHosp"
},

实际结果:

VM1588 WAService.js:2 TypeError: Cannot read property '0' of undefined
at vendor.js? [sm]:1033
at Array.forEach (<anonymous>)
at getExtraValue (vendor.js? [sm]:1010)
at vendor.js? [sm]:1091
at Array.forEach (<anonymous>)
at processEventExtra (vendor.js? [sm]:1071)
at processEventArgs (vendor.js? [sm]:1122)
at vendor.js? [sm]:1230
at Array.forEach (<anonymous>)
at vendor.js? [sm]:1201
errorReport @ VM1588 WAService.js:2
thirdErrorReport @ VM1588 WAService.js:2
(anonymous) @ VM1588 WAService.js:2
(anonymous) @ VM1588 WAService.js:2
n.safeCallback @ VM1588 WAService.js:2
n.call @ VM1588 WAService.js:2
message @ VM1588 WAService.js:2
n.safeCallback @ VM1588 WAService.js:2
(anonymous) @ VM1588 WAService.js:2
a @ VM1588 WAService.js:2
(anonymous) @ VM1588 WAService.js:2
n @ VM1588 WAService.js:2
(anonymous) @ VM1588 WAService.js:2
(anonymous) @ VM1588 WAService.js:2
i @ VM8 asdebug.js:1
c @ VM8 asdebug.js:1
(anonymous) @ VM8 asdebug.js:1
f @ VM8 asdebug.js:1
g @ VM8 asdebug.js:1
(anonymous) @ VM8 asdebug.js:1
_ws.onmessage @ VM8 asdebug.js:1

bug描述:

小程序环境中用v-for渲染的元素,绑定click事件的传参存在bug

2021-04-08 16:01 负责人:无 分享
已邀请:
DCloud_UNI_Anne

DCloud_UNI_Anne

不想你丶

不想你丶 - 90IT男

我也出现了这种情况,点击的时候提示这个错误,不带参数就没有问题

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