今天点击社保小程序某个月份的缴费详情弹框的时候,提示如图所示的错误
经过断点调试,发现是以下代码出现了问题。var index = e.target.dataset.zbparam;
这里取到的index值为underfine
,所以通过this.setData({})
将insurance_DetailListData数组中某个索引的值赋值给*左侧的new_insurance_DetailListData的时候,索引index的值为undifine
,因此报了如上截图的错误
showModal:function(e){
var that = this;
var index = e.target.dataset.zbparam;// 有问题
this.setData({
new_insurance_DetailListData: this.data.insurance_DetailListData[index],
shebaofeiyong_select: false,
})
var animation = wx.createAnimation({
duration: 600, //动画的持续时间 默认400ms 数值越大,动画越慢 数值越小,动画越快
timingFunction: 'ease', //动画的效果 默认值是linear
})
this.animation = animation
setTimeout(function () {
that.fadeIn(); //调用显示动画
}, 200)
},
断点定位到了问题,如下图所示
解决办法:
将var index = e.target.dataset.zbparam;
替换成var index = e.currentTarget.dataset.zbparam;
,index就有值了,然后就可以从insurance_DetailListData
数组中通过索引index取出数据,赋值给左边的new_insurance_DetailListData了。
showModal:function(e){
var that = this;
var index = e.currentTarget.dataset.zbparam;
this.setData({
new_insurance_DetailListData: this.data.insurance_DetailListData[index],
shebaofeiyong_select: false,
})
var animation = wx.createAnimation({
duration: 600, //动画的持续时间 默认400ms 数值越大,动画越慢 数值越小,动画越快
timingFunction: 'ease', //动画的效果 默认值是linear
})
this.animation = animation
setTimeout(function () {
that.fadeIn(); //调用显示动画
}, 200)
},