赞
踩
要传递的参数是:
username:'admin'
password:'111111'
方法一:
- var params = new URLSearchParams();
- params.append('username', username);
- params.append('password', password);
- this.$axios({
- method: 'post',
- url:url,
- data:params
- }).then((res)=>{
- console.log(res);
- });
方法二:
- import qs from 'qs';
- let params=qs.stringify({
- username:username,
- password:password
- });
- this.$axios.post(url,params).then(res=>{
- console.log(res);
- })
axios请求的时候带上请求头 token验证
方法一:
- this.$axios.defaults.headers.common['Authorization']=token;
- this.$axios.get('http://localhost:8080/test/3')
方法二:
- let config={
- Authorization:token
- }
- this.$axios.get('http://localhost:8080/test/3',{
- headers: config,
- })
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。