In JS, each function class has a arguments object instance arguments. First of all, he is not an array, it can be said to be a pseudo-array, but the index of the array can also get his value, such as
Let len = Arguments.length; Indicates the number of function arguments
Arguments[0] represents the first parameter
The advantage of using it in a function is that the function is called in multiple places and the parameters do not have to be passed, so it can be handled by using arguments, which solves the problem of unnecessary parameters being passed.
In the actual application of the function of the use of a bit, there is not the right and need to improve the place, but also please give us a lot of advice, study together
Export function Axiospost () {
Let len = arguments.length;
if (Len < 4) {
Alert (' Please check ' for incorrect parameters);
Return
}
Let that = arguments[0];
Let URL = arguments[1];
Let params = arguments[2];
Let callback = Arguments[3];
Let message;
let config;
if (len = = = 4) {
message = ";
config = {};
}
else if (len = = 5) {
config = arguments[4];
message = ";
}
else {
config = arguments[4];
message = Arguments[5];
}
Axios.post (URL, params, config)
. then (function (respons) {
Processresponsedata (That,respons,message,callback);
})
. catch (function (error) {
That. $message ({
Message: ' There is a problem with the data response ',
Type: ' ERROR '
});
});
}
This is a POST request encapsulation, is used in the Vue project, using Axios instead of Ajax to do the interaction, because the first four parameters must be passed, and then two parameters are not necessary is to do the expansion of use
The application of arguments in JS