<template>
  <div>
    <video :src="videoUrl" ref="videoPlayer"></video>
    <button @click="play">Play</button>
    <button @click="pause">Pause</button>
  </div>
</template>
<script setup>
import { ref } from 'vue';
import videoUrl from '@/assets/video.mp4';

const videoPlayer = ref(null);
const isPlaying = ref(false);

function play() {
  videoPlayer.value.play();
  isPlaying.value = true;
}

function pause() {
  videoPlayer.value.pause();
  isPlaying.value = false;
}
</script>
用element-plus框架插入视频组件生成vue3格式 script setup代码要求变量为响应式要求函数用function定义无需任何文字说明只要源码即可

原文地址: https://www.cveoy.top/t/topic/bbEQ 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录