微信小程序(mpvue)—解決視頻播放bug的一種方式

// 第一頁ide

<div @click="play(video.src, video.width, video.height)"></div>this

methods: {spa

  play (src, width, height) {router

    this.$router.push({path: `/pages/playVideo?src=${src}&width=${width}&height=${height}`})get

  }it

}io

// 第二頁class

<div class="video-box">
<video class="video"
  :style="{width: width, height: height}"
id="video"
:src="src"
show-play-btn
controls
autoplay="true"
objectFit="cover"
:show-fullscreen-btn="fullscreenShow"
custom-cache="false"
></video>
</div>
export default {
data () {
return {
width: '100%',
height: '100%',
src: '',
fullscreenShow: false,
videoObj: wx.createVideoContext('video')
 }
},
onLoad () {
this.src = this.$route.query.src
 const width = this.$route.query.width
const height = this.$route.query.height
if (width > height) {
const radio = width / wx.getSystemInfoSync().windowWidth
this.width = width / radio + 'px'
this.height = height / radio + 'px'
this.fullscreenShow = true
} else {
this.fullscreenShow = false
}
}
}
相關文章
相關標籤/搜索