[Vue.js--axios.post to send form data to the background is empty object to solve the problem]

tags: vue.js

The data is transferred here in the form of objects, and the official document explains: By default, the data objects will be converted into JSON format and sent to the server. The format of the transferred data should be string format name=cxf&gender=
Official document:https://www.npmjs.com/package/axios

login(){
	let { username,password } = this;
	this.axios.post('/user/login.do',{
            headers: { 'content-type': 'application/x-www-form-urlencoded' }
        },
            {
                params: {username:username,password:password}
            }).then((res)=>{
					this.res = res;
					this.$router.push('/index');
				});
			},

You only need to add the declaration header, you can add it globally or in the method.

Intelligent Recommendation

How to solve the problem with the Axiospost data automatically send JSON type encoding (AXIOS Send Application / X-WWW-FORM-URLENCoded Type Data)

This document is a backup version of the personal blog document system, the author: small tour, author blog:Click to access Axios's request default data will automatically perform JSON encoding. . . H...

Java background Send form form data using HTTP

HTTP send form Submit data in the background using HTTP to send Form form Submit data in the background using HTTP to send Form form...

How to convert multiple lines of data in form form into json and send it to the background

Foreach data, you need to export the data. In theory, you need to use the background query, but the gap between the background and the front-end Baidu API provides a longitude and latitude algorithm t...

Solve the problem that the form is submitted to the background data of the web is garbled, and the background data is normal but the data is garbled when receiving data in the idea

Data garbled problem when the form is submitted to the web background: Check the encoding format in the html/jsp file, you need to change the encoding format toUTF-8 The background data is normal but ...

Winform application form to solve the problem of flicker background

This article is reproduced: https: //my.oschina.net/Tsybius2014/blog/659742 My OS is Win7, VS version using VS2012, the text of the code is C # code. These days encountered a problem that I use an emb...

More Recommendation

C # to solve the problem of flicker form load background

When using panel panel, set the background picture after each run is always flashing, solutions  ...

Submit a form to the background and solve the problem of Chinese garbled

First set the JSP file representation page: Second, set the controller module to run its content: After setting the format of the output content: Run Tomcat. Bane, when the form is submitted as Chines...

Use vue.js ElementUI form to submit FormData data to the background

Front-end style renderings: Main code of front-end style: The front end submits the function code of registered user information:   Background java code   The first step: Create a new formDa...

Solve the problem of repeated submission of data when the form data is submitted in the background, repeated F5 refresh page.

How it works: The page sets a key value, and when the data is added, it is sent to the backend together, and the backend writes a TokenProcessor class to determine whether the key value of each submis...

axios.post with request head and data

axios.post with request head and data The first step is introduced into AXIOS...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top