I used Vue element to write a background management system before, but when logging in using axios to request data and parameters, the data could not be obtained normally. Afterwards, I also tried Baidu and found out that the reason was that the parameters needed to be serialized when passing them.
The qs plug-in is used here:
Simply put, qs is a query string parsing that adds some security and a library for serializing strings.
Use the command line tool in the project and enter: npm install qs
After the installation is completed, in the components that need to be used: import qs from 'qs'
In specific use I checked: qs.parse() and qs.stringify()
Although these two methods are both serialization, there are still differences.
qs.parse() is the form of parsing the URL into an object
qs.stringify() is the form of serializing the object into the URL, spliced with &
To solve the problem I encountered, I used qs.stringify()
Directly above, a simple login request example:
The above is the detailed content of What is vue qs. For more information, please follow other related articles on the PHP Chinese website!