
微信小程序切图之绑定事件带参数
1.index.wxml
<!--index.wxml-->
<view class="container">
<view id="textMessage" class="usermotto">
<!--data-user-name,data-不支持大写,但可以用驼峰代替大写-->
<text data-userid="123456" data-user-name="parry" class="user-motto" id="user-{{userId}}" bindtap="tapMessage">{{motto}}</text>
</view>
</view>
2.index.js
//index.js
//获取应用实例
const app = getApp()
Page({
data: {
motto: 'Hello World',
userId: '123',
},
onLoad: function() {},
onShow: function() {
// app.globalData.userInfo="wxopen.club";
},
tapMessage: function(event){
console.log(event);
console.log("data-userid:" + event.currentTarget.dataset.userid);
console.log("data-user-name:" + event.currentTarget.dataset.userName);
}
})
关注“qietuwang”微信公众号,获取一手干货内容推送
本文由切图网原创,转载请保留版权:
微信扫一扫二维码访问