微信小程序事件传参与vue传参的不同

1、vue点击事件传参(day)的写法:

<view @click="process(day)"></view>

2、微信小程序写法 (1)事件传参

<view bindtap="process" data-day="{{day}}"></view>

(2)获取参数day

process(e){
console.log(e.currentTarget.dataset.day)
}

3、总结:微信小程序不支持事件传参,可以通过把参数绑定在元素上,通过currentTarget.dataset获取参数。

评论

h
hw_7864

⭐️ Admin快速开发: https://show.cool-admin.com/

赞 0
h
hw_7864

⭐️ 官方文档: https://cool-js.com

赞 0
h
hw_7864

⭐️ chatgpt在线体验: https://cool-js.com/ai/chat-vip/index.html?r=helloworld

赞 0