登录
This commit is contained in:
parent
4a323995f9
commit
40ded001f8
15
src/components/Home.vue
Normal file
15
src/components/Home.vue
Normal file
|
@ -0,0 +1,15 @@
|
|||
<template>
|
||||
<div>
|
||||
home组件
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'Home'
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
|
@ -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 () {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
]
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module.exports = {
|
||||
devServer: {
|
||||
port: 8887,
|
||||
open:true,
|
||||
open: true
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user