微信小程序中wxml中用data-id传出的数据在js中的获取方法。

wxml:
view bindtap=”touch” data-id=”{{id}}”
//{{id}}这里的id为js里面设置的数据;
js:
touch:function(e){
var id = e.target.dataset.id;
console.log(id);
}

这样就可获取到前台页面通过点击事件传过来的值了。

猜你喜欢

转载自blog.csdn.net/hansiqi0817/article/details/81462324