quasar的组件 <q-uploader>文件上传组件


<template>
             <q-uploader
              flat
              dark
              label="抖店所需的三张图片"
              ref="techUploaders"
              :field-name="(file) => 'file'"
              url="http://www.xxxxxx.com:9201/miniofile/upload"
              auto-upload
              :max-files="3"
              :headers="headers"
              @uploaded="uploaded"
              @removed="removeFile"
              multiple
               />
</template>

<script>

  computed: {
    ...mapState("login_tab",[
      "usertoken",
    ]),
  },

  headers() {
      //函数在上传图片之前被调用
      return [
        { name: "Authorization", value: this.usertoken },
        { name: "Accept", value: "application/json, text/plain, */*" },
      ];
   },

 //文件或批量文件已上传时发出
  uploaded(info) {
      let res = JSON.parse(info.xhr.response);
      this.fileCount++;

      this.DouYinImage.push(res.data.url);
      this.addlesson.scourseImage = this.DouYinImage[0];
      this.addlesson.tcourseImage = this.DouYinImage[1];
      this.addlesson.douyinDescImage = this.DouYinImage[2];
   },

    // removed从列表中删除文件时发出    
    //reset()将上传程序重置为默认值;清空队列,中止当前上传
    removeFile(files) {
      this.$refs["techUploaders"].reset();
      this.DouYinImage = [];
    },

</script>

headers: Array | Function
Examples:

1  [{name: 'Content-Type', value: 'application/json'}, {name: 'Accept', value: 'application/json'}]

2 () => [{name: 'X-Custom-Timestamp', value: Date.now()}]

3 files => [{name: 'X-Custom-Count', value: files.length}]

有问题可以评论问我

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值