vue项目 使用simple-uploader进行携带参数进行文件和文件夹上传

介绍:由于element的el-upload不支持文件夹上传,所以用了vue-simple-uploader,实现了文件夹/文件的携带form data 和 headers参数上传。vue-simple-uploader还能用于切分上传、断续上传,此处项目没有用到。

想对上传做更多的处理的小伙伴,推荐去看源码。

另:以下代码加了文件列表的拖拽。

 

1、安装:npm install vue-simple-uploader --save

在main.js里 加上:

import uploader from 'vue-simple-uploader'

Vue.use(uploader)

2、

    <uploader
          ref="uploader"
          :options="options"
          :autoStart="false"
          @file-added="onFileAdded"
          @file-success="onFileSuccess"
          @file-progress="onFileProgress"
          @file-error="onFileError"
          @class="uploader-app"
        >
          <uploader-unsupport></uploader-unsupport>
          <uploader-btn id="global-uploader-btn" :attrs="attrs" ref="uploadBtn">{
  {$t('imgUpload.file')}}</uploader-btn>
          <uploader-btn :directory="true">{
  {$t('imgUpload.folder')}}</uploader-btn>
          <uploader-list v-show="panelShow">
            <div id="filePanel" 
              v-drag
              draggable="false"
              class="file-panel"
              :class="{'mini': collapse}"
              slot-scope
评论 36
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值