Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
robot-monitor
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
汪晓凯
robot-monitor
Commits
fde0c879
Commit
fde0c879
authored
Sep 14, 2018
by
汪晓凯
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加路由守卫
parent
dc1c2368
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
7 deletions
+19
-7
index.js
src/router/index.js
+19
-7
No files found.
src/router/index.js
View file @
fde0c879
...
...
@@ -3,7 +3,7 @@ import Router from 'vue-router'
Vue
.
use
(
Router
)
export
default
new
Router
({
const
router
=
new
Router
({
routes
:
[
{
path
:
'/'
,
...
...
@@ -24,11 +24,11 @@ export default new Router({
children
:
[
{
path
:
'/monitor/account'
,
component
:
function
(
resolve
){
require
([
'../views/account.vue'
],
resolve
);
},
},{
path
:
'/monitor/account'
,
component
:
function
(
resolve
){
require
([
'../views/account.vue'
],
resolve
);
},
},{
path
:
'/monitor/coinRecharge'
,
component
:
function
(
resolve
){
require
([
'../views/coinRecharge.vue'
],
resolve
);
...
...
@@ -52,8 +52,20 @@ export default new Router({
},
},
]
}
}
]
},
]
})
//配置路由守卫
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
//在每次涂油跳转的时候都触发一次
if
(
to
.
matched
.
length
===
0
)
{
// 如果未匹配到路由
from
.
name
?
next
({
name
:
from
.
name
})
:
next
(
'/'
);
// 如果上级也未匹配到路由则跳转登录页面,如果上级能匹配到则转上级路由
}
else
{
next
();
// 如果匹配到正确跳转
}
});
export
default
router
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment