diff --git a/src/components/Login.vue b/src/components/Login.vue index 8ac3589..e1ad12c 100644 --- a/src/components/Login.vue +++ b/src/components/Login.vue @@ -4,24 +4,27 @@
后台管理系统
- - - - - - - - - 登录 - + + + + + + + + + 登录 + @@ -41,8 +44,20 @@ export default { methods: { login(form) { this.$refs[form].validate((valid) => { - if(valid) { + if (valid) { console.log(this.form) + this.axios.post('http://127.0.0.1:9999/web/login', this.form) + .then(res => { + console.log(res) + if(res.status === 200) { + localStorage.setItem('username',res.data.username) + this.$message({message: '登录成功', type: 'success'}) + this.$router.push('/home') + } + }) + .catch(err => { + console.error(err) + }) } else { console.error(this.form) } @@ -50,8 +65,8 @@ export default { } } } - + \ No newline at end of file diff --git a/src/router/index.js b/src/router/index.js index d114c00..a849c7f 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -8,12 +8,12 @@ export default new Router({ { path: '/', redirect: '/login', - component: () => import('@/components/Login') + component: () => import('@/components/Login.vue') }, { path: '/login', name: 'Login', - component: () => import('@/components/Login') // 异步引入 + component: () => import('@/components/Login.vue') // 异步引入 }, { path: '/home',