在 a-upload中加上:headers=“headers”
1
2 3 4 5 6 7 8 9 10 11 |
<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写法取得)
1
2 3 4 5 |
headers: {
‘Access-Token-PC’: this.$store.state.user.token, // ‘Authentication’: this.$store.state.user.token, // ‘Content-Type’: ‘application/json’ }, |
注:每个后端的传递方式不一样,所以不要照抄。
评论0