当前位置:   article > 正文

vue上传文件夹+上传文件vue-simple-uploader_vue 上传文件夹

vue 上传文件夹

vue上传文件夹+上传文件vue-simple-uploader
在这里插入图片描述
使用插件
在main.js引入

import uploader from 'vue-simple-uploader'

Vue.use(uploader);
  • 1
  • 2
  • 3
 <el-dialog title="上传文件" :visible.sync="dialogFileVisible" width="50%" :before-close="handleFileClose"
      :close-on-click-modal="false" class="myfiletoUploadcs">
      <div style="width:100%; display:flex; justify-content:center;">
        <uploader :key="uploader_key" :options="options" class="uploader-example" @file-success="onFileSuccess"
          ref="uploader" @file-complete="isComplete">
          <uploader-unsupport></uploader-unsupport>
          <uploader-drop>
            <uploader-btn :directory="true" :single="true">上传文件夹</uploader-btn>
            <uploader-btn>上传文件</uploader-btn>
          </uploader-drop>
          <uploader-list></uploader-list>
        </uploader>
      </div>
    </el-dialog>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  uploader_key: new Date().getTime(), //这个用来刷新组件--解决不刷新页面连续上传的缓存上传数据(注:每次上传时,强制这个值进行更改---根据自己的实际情况重新赋值)
        options: {
          target: this.baseurl +
            "/common/uploadFolder", ///antiqueRecord/upload_folder1针对只有一层文件夹 //SpringBoot后台接收文件夹数据的接口
          testChunks: false, //是否分片-不分片
          chunkSize: 1024 * 1024 * 90, //每块大小
          // simultaneousUploads: 5, //并发上传块数

          headers: {
            Authorization: "Bearer " + getToken()
          },
          query: {
            cover: true,
            folderPath: ''
          },
        },
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  onFileSuccess: function (rootFile, file, response, chunk) {
        var msg = JSON.parse(response);
      },
      isComplete(suc) {
        console.log(22, suc);
        if (suc.completed) {
          this.daoru = true;
        }
      },
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/一键难忘520/article/detail/995830
推荐阅读
相关标签
  

闽ICP备14008679号