当前项目Ant Design of Vue —— Upload组件上传图片,要上传token的写法
在 a-upload中加上:headers=“headers”<a-upload:action="this.$baseURL+'/image/upload'":headers="headers":beforeUpload="beforeUpload":multiple="true":file-lis
·
在 a-upload中加上:headers=“headers”
<a-upload
:action="this.$baseURL+'/image/upload'"
:headers="headers"
:beforeUpload="beforeUpload"
:multiple="true"
:file-list="fileList"
@change="handleChange"
>
<a-button class="upbtn"> <a-icon type="upload" /> Upload </a-button>
<div style="font-size: 12px;color: #8392A7;margin-top: 16px;">图标最大尺寸为180*52比例,大小不能超过20M</div>
</a-upload>
然后在data中添加代码如下
this.$store.state.user.token(该项目通过vuex取的,具体项目按照自己的vuex写法取得)
headers: {
'Access-Token-PC': this.$store.state.user.token,
// 'Authentication': this.$store.state.user.token,
// 'Content-Type': 'application/json'
},
更多推荐
已为社区贡献6条内容
所有评论(0)