Solve the problem that the vue processes parameters in the axios post request, vueaxios
Many of my friends will definitely use axios requests when using vue, including axios, which is already included in vux, which is easy to use and clearly described in this document, however, when we use post for submission, we find that sometimes the parameters are not sent to the server. I remember this situation also mentioned in the document, here, I will record the settings so that you can use them directly next time you need them. You do not need to read the Old Code.
The following is how to use vux. It is very simple to place the code in main. js. If you only use vue and directly install axios, the setting method is the same and will not be recorded.
Import qs from 'qs' import es6Promise from 'es6-promise 'import {AjaxPlugin} from 'vux 'vue. use (AjaxPlugin) AjaxPlugin. $ http. defaults. headers. post ['content-type'] = 'application/x-www-form-urlencoded' // POST parameter serialization (add request interceptor) AjaxPlugin. $ http. interceptors. request. use (config) => {// do something before sending the request if (config. method = 'post') {config. data = qs. stringify (config. data)} return config}, (error) =>{ return error })
Note:Placed before new Vue ({})
The above article solves the problem of using vue to process the axios post request for parameter passing. It is all the content that I have shared with you. I hope you can give us a reference and also hope you can provide more support for the customer's house.