axios default request not to bring a cookie, you need to set up their own
Method One: Global Settings:
In main.js entry file configuration
import axios from 'axios'
// 全局设置 axios 发送请求带上cookie
axios.defaults.withCredentials = true
Method two: Use setting:
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)
})
}