微信小程式把玩(二十九)video元件
阿新 • • 發佈:2019-01-31
視訊播放元件與圖片載入元件也沒啥差別,使用起來也沒啥注意的
重要屬性:
wxml
<!--監聽button點選事件-->
<button bindtap="listenerButton">點選顯示視訊元件</button>
<!--視訊元件src資源地址,binderror為監聽錯誤資訊-->
<video
src="http://mvvideo1.meitudata.com/575c2b652d7375255.mp4"
style="width: 100%; height: 100%"
hidden="{{hiddenVideo }}"
binderror="listenerVideo" />
js
Page({
data:{
// text:"這是一個頁面"
hiddenVideo: true
},
/**
* 監聽視訊載入錯誤狀態
*/
listenerVideo:function(e) {
console.log(e.detail.errMsg);
},
/**
* 監聽button點選事件
*/
listenerButton:function() {
this.setData({
hiddenVideo: !this .data.hiddenVideo
})
}
})