參考:
https://www.cnblogs.com/qwert1/p/8909455.html
https://blog.csdn.net/qq_42984640/article/details/89923797
https://blog.csdn.net/qq_42394457/article/details/96769170
https://blog.csdn.net/Zxiuping/article/details/89556035
需要創建純凈的axios,使用普通封裝的axios發送dataform后,數據會為空
這里我 通過將axios 改寫為 Vue 的原型屬性,在組件中使用axios
首先在 main.js 中引入 axios
// 將 axios 改寫為 Vue 的原型屬性 import axios from 'axios' Vue.prototype.$ajax = axios
直接在組件的 methods 中使用 $ajax 命令
this.$ajax({ method: "post", url: "/zy-api/item/medicinal/medicinalimg", data: imgfile }).then(resp => { if (resp.data.flag != true) { // 失敗 this.$message({ message: "上傳葯材圖片失敗", type: "warning" }); } });