<template>
  <div>
    <input type='file' ref='videoInput' @change='uploadVideo' accept='video/*'>
    <video :src='videoUrl' controls></video>
  </div>
</template>
<script setup>
  import { ref } from 'vue';

  const videoUrl = ref('');

  function uploadVideo() {
    const file = this.$refs.videoInput.files[0];
    const reader = new FileReader();
    reader.onload = function() {
      videoUrl.value = reader.result;
    };
    reader.readAsDataURL(file);
  }
</script>
Vue3 Element Plus 视频上传组件代码示例 (script setup, function 定义, ref 响应式)

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

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