方法1(默認方式):ios
<el-upload action="http://irhfuwu.com:5566/OE/UploadFile/AttachUpload"; multiple :limit="3" :headers="myHeaders" //注:此處也能夠使用computed來傳動態值 :on-success="sucH"> <el-button size="small" type="primary">點擊上傳1</el-button> </el-upload> ... data: { myHeaders: { token: "324234234234324343pz9cvbg3Rw=" } },
方法2(不用action,改用自寫ajax方式):ajax
<el-upload action="#" :before-upload="beforeUpload" multiple :limit="3" :on-success="sucH"> <el-button size="small" type="primary">beforeUpload方式上傳</el-button> </el-upload> .... beforeUpload:function (file) { var fd = new window.FormData(); fd.append('key', file, 'fileName') axios.post("http://irhfuwu.com:5566/OE/UploadFile/AttachUpload";, fd, { headers: { token: "456436523YZgX6PXALReS5l51QwzVf0eQnYvDJJBKxG91Wpz9cvbg3Rw=" } }).then(function (res) { console.log(res); }); return false // 返回false不會自動上傳 }