vue-admin-template 登录页面修改 作者:马育民 • 2022-09-24 09:49 • 阅读:10090 [vue-admin-template 目录](https://www.malaoshi.top/show_1IX2LobgPU2c.html "vue-admin-template 目录") ### 登录名校验规则 [](/upload/0/0/1IX46aMoCqo7.png) ### 登录事件 ``` handleLogin() { this.$refs.loginForm.validate(valid => { if (valid) { this.loading = true // this.$store.dispatch('user/login', this.loginForm).then(() => { // this.$router.push({ path: this.redirect || '/' }) // this.loading = false // }).catch(() => { // this.loading = false // }) axios.defaults.withCredentials = true;//带cookie axios.post('http://localhost:8080/login', // { // "username":this.loginForm.username, // "password":this.loginForm.password // } this.loginForm ) .then((res) => { console.log(res); console.log(res.data) if(res.data.status == 0){ this.$router.push({ path: this.redirect || '/' }) }else{ this.$message.error(res.data.message); } this.loading = false }) .catch(function (error) {// 请求失败处理 console.log(error); this.loading = false }); } else { console.log('error submit!!') return false } }) } ``` 原文出处:http://malaoshi.top/show_1IX46aOIRhoF.html