当前位置:   article > 正文

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

qusarar q-file 上传文件
  1. <template>
  2. <q-uploader
  3. flat
  4. dark
  5. label="抖店所需的三张图片"
  6. ref="techUploaders"
  7. :field-name="(file) => 'file'"
  8. url="http://www.xxxxxx.com:9201/miniofile/upload"
  9. auto-upload
  10. :max-files="3"
  11. :headers="headers"
  12. @uploaded="uploaded"
  13. @removed="removeFile"
  14. multiple
  15. />
  16. </template>
  17. <script>
  18. computed: {
  19. ...mapState("login_tab",[
  20. "usertoken",
  21. ]),
  22. },
  23. headers() {
  24. //函数在上传图片之前被调用
  25. return [
  26. { name: "Authorization", value: this.usertoken },
  27. { name: "Accept", value: "application/json, text/plain, */*" },
  28. ];
  29. },
  30. //文件或批量文件已上传时发出
  31. uploaded(info) {
  32. let res = JSON.parse(info.xhr.response);
  33. this.fileCount++;
  34. this.DouYinImage.push(res.data.url);
  35. this.addlesson.scourseImage = this.DouYinImage[0];
  36. this.addlesson.tcourseImage = this.DouYinImage[1];
  37. this.addlesson.douyinDescImage = this.DouYinImage[2];
  38. },
  39. // removed从列表中删除文件时发出
  40. //reset()将上传程序重置为默认值;清空队列,中止当前上传
  41. removeFile(files) {
  42. this.$refs["techUploaders"].reset();
  43. this.DouYinImage = [];
  44. },
  45. </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}]

有问题可以评论问我

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/515940
推荐阅读
相关标签
  

闽ICP备14008679号