參考:https://www.cnblogs.com/wuhairui/p/14048152.html
我的情況:vue + antD實現文件上傳功能,本地啟動時控制台會報404,放到服務器上控制台會報405
原因:upLoad有默認的上傳事件
解決:阻止默認事件即可
代碼:
···
<a-upload accept=".doc,.docx,.xlsx,.xls,.pdf,.ofd" :showUploadList="false" :beforeUpload="beforeUploadMains"> <a-button :disabled="mains.length >= 1">上傳附件</a-button> </a-upload>
···
beforeUploadMains(d, e) { // 自定義上傳事件
let that = this;
···
return false; // 《《= 關鍵 阻止upload默認上傳事件
},