vue/cli axios post的使用及Authorization值传递
vue/cli axios post的使用及Authorization值传递main.js引用:import axios from 'axios';Vue.prototype.$http = axios;axios.defaults.baseURL = "http://localhost:8080/";程序中使用:let header = {headers: {"Access-C
·
vue/cli axios post的使用及Authorization值传递
main.js引用:
import axios from 'axios';
Vue.prototype.$http = axios;
axios.defaults.baseURL = "http://localhost:8080/";
程序中使用:
let header = {
headers: {
"Access-Control-Allow-Origin": "*", //解决cors头问题
"Access-Control-Allow-Credentials": "true", //解决session问题
"Content-Type":
"application/x-www-form-urlencoded; charset=UTF-8", //将表单数据传递转化为form-data类型
Authorization: "hezhongxia",
},
withCredentials: true, //此处不使用,采用nginx 时,post接收不了数据
};
let url = "/userlogin";
this.$http.get(url, this.loginForm, header).then(function (rep) {
console.log(rep);
});
更多推荐
已为社区贡献1条内容
所有评论(0)