<Upload action="/sys/mts/uploadFile"
:headers="headers"
:with-credentials= true
:before-upload="handleUpload"
:show-upload-list="showUploadList"
style="margin-left: 131px; margin-top: -30px;"
></Upload>
相關(guān)內(nèi)容補(bǔ)充:
headers: {
'Access-Control-Allow-Origin' : '*'
},
credentials: true
謝謝各位大佬!
5 回答

米琪卡哇伊
TA貢獻(xiàn)1998條經(jīng)驗(yàn) 獲得超6個(gè)贊
'Access-Control-Allow-Origin' : '*'
要在后臺(tái)設(shè)置 前臺(tái)設(shè)置沒(méi)用 反而會(huì)讓請(qǐng)求變成非簡(jiǎn)單請(qǐng)求

陪伴而非守候
TA貢獻(xiàn)1757條經(jīng)驗(yàn) 獲得超8個(gè)贊
跨域文件上傳實(shí)際上就是跨域請(qǐng)求,如果你是vue-cli生成的項(xiàng)目,在config文件下,找到index.js,在里面配置跨域就行了。例如:
proxyTable: {
'/api': {
target: '你的服務(wù)器地址',
changeOrigin: true,
pathRewrite: {
'^/api': '',
},
}
},
請(qǐng)求時(shí),在所有接口前面加上/api/你的接口名稱(chēng),就可以實(shí)現(xiàn)跨域。
添加回答
舉報(bào)
0/150
提交
取消