写在前:这是使用官方提供的方式实现视频播放(自动播放)可切换 官方api
实现:
<template>
<!-- 测试-->
<div id="palyback">
<div :class="{'else': onswitch}">
<div id="player-container-id"></div>
</div>
<div :class="{'else': !onswitch}">
<div id="player-container"></div>
</div>
<div class="box-title" @click="onchange">切换</div>
</div>
</template>
<script>
export default {
data() {
return {
player: null,
onswitch: false
}
},
mounted() {
this.playVideo()
},
methods: {
playVideo() {
document.getElementById('player-container-id').innerHTML = ""
this.play