1.视频标签:
<video class="videoclass" style="width: 100%; height: auto; margin-bottom: 8px;" src="" controls="controls"></video>
2.获取所有video、dom
this.$nextTick(() => {
let video = document.getElementsByClassName("videoclass");
let arr = [...video].length;
if (arr > 0) {
for (let i = 0; i < [...video].length; i++) {
[...video][i].addEventListener("playing", function (e) {
for (let j = 0; j < [...video].length; j++) {
if (i != j) {
console.log(j);
[...video][j].pause();
}
}
[...video][i].play();
});
}
}
});