微信小程序——tap undefined Setting data field "currType" to undefined is invalid.

微信小程序,点击tap 赋值报这个错误。

tapType: function (e){

var that = this;

console.log(e)

const currType = e.currentTarget.dataset.typeId;

that.setData({

currType:currType

});

},

然后打印console.log(e) 》{type: "tap", timeStamp: 1387, target: {…}, currentTarget: {…}, detail: {…}, …}

展开发现有,target,currentTarget,我们获取当前数据。currentTarget:{id""offsetLeft0offsetTop50dataset{…}}

所以点击currentTarget 展开dataset:{type_id"2"

所以应该是e.currentTarget.dataset.type_id

发布了30 篇原创文章 · 获赞 16 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/Asia_ZhangQQ/article/details/79279436
今日推荐