比如在popupDom和text这里都需要关闭当前这个弹框 可以给他们定义一个一样的事件data-target="self" catchtap='hideBaitiaoView'
index.wxml
<!-- 白条弹框 -->
<view class='popupDom' hidden='{{hideBaitiao}}' data-target="self" catchtap='hideBaitiaoView'>
<view class='pop_main'>
<view class='pop_header'>
打白条购买
<text catchtap='hideBaitiaoView' data-target="self">x</text>
</view>
</view>
</view>
index.js
// components/IOU/index.js
Component({
/**
* 组件的属性列表
*/
properties: {
hideBaitiao: { // 是否隐藏白条的遮罩
type: Boolean,
value: true
}
},
/**
* 组件的初始数据
*/
data: {
selectIndex: 0 // 选中的下标
},
/**
* 组件的方法列表
*/
methods: {
hideBaitiaoView: function (e) { // 隐藏白条弹框
//需求点击多个指定的地方;关闭白条弹框,我在指定的地主用了data-target="self"这边用这判断就可以
if (e.target.dataset.target == 'self')
this.setData({
hideBaitiao: true
})
},
}
})