参考:
1:https://www.jianshu.com/p/2578cc444b70
2:https://blog.csdn.net/weixin_43851769/article/details/86505164
3:http://www.cnblogs.com/jszhp/p/10142904.html
登录部分:axios,post方法
Login() {
this.$axios.post('xxx接口地址', this.$qs.stringify({
userName: this.userName,
password: this.password
})).then((res) => {
// console.log('login success');
// console.log(res);
// console.log(res.data.status);
if(res.data.status=='ok'){
let ses=window.sessionStorage;
let d=JSON.stringify(res.data[0])
ses.setItem('data',d)
alert('登录成功')
this.$router.push('/teacher');
}else {
alert('账号或密码错误')
}
}).catch(() => {
this.loading = false
})
在router.js中:在需要登录的路由中添加字段
main.js中:安装qs类库,axios
完成