1.index.wxml
<!--index.wxml-->
<view class="container">
<view id="outter" bindtap="handleTap1">
outer view
<!-- catchtap阻止冒泡 -->
<view id="middle" catchtap="handleTap2">
middle view
<view id="inner" bindtap="handleTap3">
inner view
</view>
</view>
</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.target.dataset.userid);
console.log("data-user-name:" + event.target.dataset.userName);
},
handleTap1: function () { console.log("handleTap1"); },
handleTap2: function () { console.log("handleTap2"); },
handleTap3: function () { console.log("handleTap3"); },
})