vue + elementPlus 分片上传大视频文件

在Vue和Element Plus中分片上传大视频文件涉及将大文件切分成小块(分片),然后逐个上传到服务器。Element Plus的<el-upload>组件提供了上传文件的基本功能,但对于分片上传,我们需要自己处理逻辑。

以下是一个使用Vue 3和Element Plus实现分片上传大视频文件的简单示例:

<template>
  <el-upload
    action="/https/blog.csdn.net/your/uploadUrl"
    :on-change="handleFileChange"
    :before-upload="beforeUpload"
    :file-list="fileList"
    :auto-upload="false"
    multiple
  >
    <el-button size="small" type="primary">选择视频文件</el-button>
  </el-upload>
</template>

<script>
import { ref } from 'vue';
import axios from 'axios';

export default {
  setup() {
    const fileList = ref([]);
    const chunkSize = 1024 * 1024; // 1MB per chunk
    const currentChunk = ref(0);
    const totalChunks = ref(0);
    const currentFile = ref(null);
    const loading = ref(false);
    const isShow = ref(true);

    const handleFileChange = async (file, fileList) => {
      console.log('file', file)
      // 判断是否是video
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值