<template>
  <div>
    <input type="file" ref="fileInput" style="display: none" @change="handleFileInputChange" accept="video/*">
    <el-button type="primary" @click="handleUploadClick" :loading="uploading">上传视频</el-button>
  </div>
</template>
<script setup>
import { ref } from 'vue';

const file = ref(null);
const uploading = ref(false);

function handleFileInputChange(event) {
  file.value = event.target.files[0];
}

function handleUploadClick() {
  uploading.value = true;
  const formData = new FormData();
  formData.append('video', file.value);
  // 发送上传请求,上传成功后将uploading置为false
}

</script>
用element-plus框架插入视频上传组件生成vue3生成vue3格式 script setup代码要求所有方法或箭头函数都用function定义要求所有变量为ref响应式无需任何文字说明只要源码即可

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

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