This commit is contained in:
xing 2020-06-16 15:20:27 +08:00
parent 4a323995f9
commit 40ded001f8
4 changed files with 31 additions and 7 deletions

15
src/components/Home.vue Normal file
View File

@ -0,0 +1,15 @@
<template>
<div>
home组件
</div>
</template>
<script>
export default {
name: 'Home'
}
</script>
<style scoped>
</style>

View File

@ -26,8 +26,8 @@ export default {
data () {
return {
loginForm: {
username: '',
password: ''
username: 'admin',
password: '123456'
},
loginFormRules: {
username: [
@ -49,8 +49,11 @@ export default {
}
const { data: res } = await this.$http.post('login', this.loginForm)
if (res.meta.status !== 200) {
return console.log('login fail')
return this.$message.error('登录失败')
}
sessionStorage.setItem('token', res.data.token)
this.$message.success('登录成功')
await this.$router.push('/home')
})
},
reset () {

View File

@ -1,6 +1,8 @@
import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../components/Login'
import Home from '../components/Home'
Vue.use(VueRouter)
const routes = [
@ -10,6 +12,10 @@ const routes = [
{
path: '/login',
component: Login
},
{
path: '/home',
component: Home
}
]

View File

@ -1,6 +1,6 @@
module.exports={
devServer:{
port:8887,
open:true,
module.exports = {
devServer: {
port: 8887,
open: true
}
}