new Vue({
el: "#app",
methods: {
fileUpload: function () {
console.info("sbkjauth:" + localStorage.getItem("sbkjauth"));
var _this = this;
var formData = new FormData();
formData.append("uploadFile", $("input[name='uploadFile']")[0].files[0]);
axios({
method: "post",
url: "/auth/fileUploadLocal" + getSign(),
data: formData,
headers: {
'Content-Type': 'multipart/form-data',
"sbkjauth": localStorage.getItem("sbkjauth")
},
}).then(function (response) {
console.log(response);
alert(response.data.message);
}).catch(function (reason) {
})
},
}
});
区别 后端接受需要 在 $param['params']
axios.post('del', {
params: {
id: id
}
}).then(function (res) {
if (res.data.code) {
layer.alert(res.data.msg);
} else {
layer.alert(res.data.msg);
}
}).catch(function (error) {
console.log(typeof +error)
})
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
!function(e,t){
"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.axios=t():e.axios=t()}(this,function(){
return function(e){
function t(r){
if(n[r])return n[r].exports;var o=n[r]={
exports:{
},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={
};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){
e.exports=n(1)},function(e,t,n){
"use strict";function r(e){
var t=new i(e),n=s(i.prototype.request,t);return o.extend(n,i.prototype,t),o.extend(n,t),n}var o=n(2),s=n(3),i=n(5),a=n(22),u=n(11),c=r(u);c.Axios=i,c.create=function(e){
return r(a(c.defaults,e))},c.Cancel=n(23),c.CancelToken=n(24),c.isCancel=n(10),c.all=function(e){
return Promise.all(e)},c.spread=n(25),e.exports=c,e.exports.default=c},function(e,t,n){
"use strict";function r(e){
return"[object Array]"===j.call(e)}function o(e){
return"[object ArrayBuffer]"===j.call(e)}function s(e){
return"undefined"!=typeof FormData&&e instanceof FormData}function i(e){
var t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer}function a(e){
return"string"==typeof e}function u(e){
return"number"==typeof e}function c(e){
return"undefined"==typeof e}function f(e){
return null!==e&&"object"==typeof e}function p(e){
return"[object Date]"===j.call(e)}function d(e){
return"[object File]"===j.call(e)}function l(e){
return"[object Blob]"===j.call(e)}function h(e){
return"[object Function]"===j.call(e)}function m(e){
return f(e)&&h(e.pipe)}function y(e){
return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams}function