首页 > 技术文章 > 微信小程序wxml的数据传给js 点击事件 js获取view中的内容

lsyy2017 2019-10-19 17:07 原文

例子

wxml:

     <view class="itemmainwhite"  bindtap="onclick" wx:if="{{item.temp==0}}" data-text="{{item.index}}">{{item.index}}
        </view>

  

js:

  onclick: function (e) {
    console.log(e.currentTarget.dataset.text);
}

  

推荐阅读