wxjs代碼:code
GetAction: function (e) { var action = e.currentTarget.dataset.action; console.log(action); //father }
wxml代碼:xml
<view data-action="father" bindtap="GetAction"> <image src="https://ss0.baidu.com/6ONWsjip0QIZ8tyhnq/it/u=1302131682=407" mode="widthFix"> </image> <text>文字</text> </view>
這是要獲取data-action這個屬性的father的這個值的方法。ip