当前位置:   article > 正文

vue文件上传携带token_a-upload 上传携带token

a-upload 上传携带token

vue文件上传

<a-upload name="file" 
          :action="uploadApi.uploadImg"
          :multiple="true"
          accept="image/gif,image/jpeg,image/jpg,image/png,image/svg"
          :headers="headers"
          :file-list="fileList"
          @preview="handlePreview"
          @change="handleChange"
          >   
            <a-button icon="upload" @click="upload"> 上传</a-button>
          </a-upload>
     export default {    
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

methods:{
data () {
return{
fileList: [],
headers: {
token: user.state.token
},
}
async handlePreview (file) {
if (!file.url && !file.preview) {
file.preview = await getBase64(file.originFileObj)
}
this.previewImage = file.url || file.preview
this.previewVisible = true
},
handleChange ({ fileList }) {
this.fileList = fileList
},

}
}

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

闽ICP备14008679号