100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > 微信小程序:bindtap传参

微信小程序:bindtap传参

时间:2023-05-14 00:56:33

相关推荐

微信小程序:bindtap传参

wxml:

使用自定义参数data-,可以通过dataset拿到对应的值

<image src="del.png" bindtap="openConfirm" data-name="出行情况{{idx+1}}"></image>

js:

如上,可以通过e.currentTarget.dataset.name拿到data-name里的值

openConfirm(e){var curname = e.currentTarget.dataset.name;wx.showModal({title: '提示',content: '确认删除【'+curname+"】?",success (res) {if (res.confirm) {console.log('删除成功')} else if (res.cancel) {console.log('用户点击取消')}}})}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。