增加了对文件的支持
async saveLocalUrl(file) {
let url = xxxxxx'
let formdata = new FormData()
formdata.append('file', file.raw)
var data = await Util.post(url, formdata, '3')
if (data.status == '200') {
}
},
// type 1 2 3
export function post(url, data = {}, type = 1) {
return new Promise((resolve, reject) => {
var myHeader
if (type == 1) {
data = qs.stringify(data)
myHeader = {
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': localStorage.getItem('token')
}
} else if (type == 2) {
myHeader = { 'Content-Type': 'application/json' }
} else if (type == 3) {
myHeader = { 'Content-Type': 'multipart/form-data' }
}
Axios.post(baseUrl.apiUrl + url, data, { headers: myHeader })
.then(response => {
resolve(response.data);
}).catch(err => {
reject(err)
})
})
}
网友评论