axios 默认请求是不会带上cookie的,所以需要自己设置 方法一:全局设置:在 main.js 入口文件配置 import axios from 'axios'
// 全局设置 axios 发送请求带上cookie
axios.defaults.withCredentials = true
方法二:使用时设置:login(){ //登录方法 由子组件回调
var params = {
account: this.account,
password: this.password
}
this.$http.post(
"/api/admin/login",
this.$qs.stringify(params),
{withCredentials: true}) //调用时设置 请求带上cookie
.then(function (response) {
console.log(response)
})
.catch(function (error) {
console.log(error)
})
|