After integrating axios, vue will send post requests in payload mode by default. If you want to change to the normal method, you need to add headers and change the sent data json format to querystring.
Installing dependencies
cnpm install qs
Importing dependencies
import Qs from 'qs'
Use the following method where post is required, where postData is a json object
this.$http({ url: '/api/act/yourApi.api', method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' }, data: Qs.stringify(postData) }) .then(res => { console.log(res); }) .catch(err => { console.log(err); })
Like this, The data sent is sent in form-urlencodoed mode.
The above is the detailed content of How to solve the problem that vue integrates axios and sends post request payload, causing the background to be unable to receive data.. For more information, please follow other related articles on the PHP Chinese website!