1:将video自动播放置为false
<video v-if="goodsInfo.video" id="videoPlayer" :autoplay="false" :enable-progress-gesture="false" :show-center-play-btn="false"
:muted="true" loop :controls="false" :src="goodsInfo.video.file_path"></video>
2:在data中定义
data() {
return {
videoContext:null
};
},
3:在onReady中创建一个视频对象
onReady() {
this.videoContext = uni.createVideoContext('videoPlayer', this);
},
4:在接口返回成功后调用
当然了,得加上nextTick
this.$nextTick(()=>{
this.videoContext.play()
})