Uly*_* BN 5 javascript vue-router vuejs2
在我的router.js文件,当我使用的beforeEach方法,我得到path和fullPath在性能to和from参数。我想知道我应该使用哪个重定向。我已经看到了两者都被使用过,我什么时候不使用,两者之间有什么区别。
例子:
export default new Router({
mode: 'history',
base: process.env.BASE_URL,
routes: [{
path: 'login'
beforeEnter: (to, from, next) => {
console.log(to, from) // the routes
if (User.loggedIn()) {
next(from.fullPath) // or maybe `from.path`
} else {
next()
}
},
}]
})
Run Code Online (Sandbox Code Playgroud)
小智 6
- $ route.fullPath
- 类型:
string
完整的解析URL,包括查询和哈希。- $ route.path
- 类型:
string
一个字符串,它等于当前路径的路径,始终解析为绝对路径。例如“ / foo / bar”。
| 归档时间: |
|
| 查看次数: |
2489 次 |
| 最近记录: |