自己学,想了个笨方法,子元素和父元素都添加绑定事件。当点击子元素时,会先调用子元素,再调用父元素的点击,利用data可实现在父元素中判断实现两个功能。
也算是两个按钮实现各自的功能,并使用同一个id
wxml
<view class="toolbar" bindtap="ceshi" id="ceshiid">
<view bindtap="ceshi1">提交名字</view>
<view bindtap="ceshi2">提交视频</view>
</view>
js
ceshi: function (e) {
var that=this;
if(that.data.isname == 2){
return
}else if(that.data.isname == 0){
console.log("video")
that.setData({
isname:2
})
}else if(that.data.isname == 1){
console.log("name")
that.setData({
isname:2
})
}
},
ceshi1: function (e) {
this.setData({
isname: 1
})
},
ceshi2: function (e) {
this.setData({
isname: 0
})
}