wxml
<view class="mul-yb {{courseChapters.state==1?'mianfke':''}}" bindtap="getVideo"
data-title="{{courseChapters.name}}"
data-currentPoster="{{courseChapters.thumbnail}}"
data-state="{{courseChapters.state}}"
data-videoId="{{courseChapters.courseVideoAddress}}"
>
js
getVideo(e) {
this.setData({
options: {
title: e.currentTarget.dataset.title, // 视频标题
currentPoster: 'images/2020/06/04/15912626515967143.jpg', // 封面图
state: e.currentTarget.dataset.title, // 1收费 2免费
videoId: '2fcc42331de5412cbccb6691394de337' // 视频id
}
})
}
data-currentPoster 和 data-videoId 这两个数据得值如何赋值到js里面
给你举个简单的例子
wxml页面:
<view bindtap='acc' data-add='{{123}}'>asdfghj</view>
js页面:
acc:function(e){
console.log(e.currentTarget.dataset.add);
}
结果:
https://blog.csdn.net/weixin_41545119/article/details/100524736
就是view里面定义 data-xxx 数据,js里面以下面的方式获取绑定的数据。。
你把那个e打印出来看一下,你就明白了!
getVideo(e) {
this.setData({
options: {
title: e.currentTarget.dataset.title, // 视频标题
currentPoster: e.currentTarget.dataset.currentPoster, // 封面图
state: e.currentTarget.dataset.state, // 1收费 2免费
videoId: e.currentTarget.dataset.videoId // 视频id
}
})
}
e.currentTarget.dataset.xxx->xxx=(data-xxx)中的xxx