vue路由6:导航钩子
发布日期:2021-05-07 01:02:38 浏览次数:12 分类:技术文章

本文共 873 字,大约阅读时间需要 2 分钟。

index.html:

    
Title
首页
登录
帖子管理

app.js:

var routes = [    {        path: '/',        component:{            template: `            

这里是首页

` } },{ path: '/login', component: { template: `

这里是登录!

` } },{ path: '/post', component: { template: `

这里是帖子管理

` } }];var router = new VueRouter({ routes: routes,});router.beforeEach(function(to, from, next){ var login_in = true; if(!login_in && to.path == '/post'){ next('/login') }else{ next(); }})router.afterEach(function(to, from){ console.log("to", to); console.log("form", from);});var app = new Vue({ el: '#app', router: router})
上一篇:DOS命令:mklink
下一篇:[JOI 2014 Final]裁剪线

发表评论

最新留言

不错!
[***.144.177.141]2025年03月11日 05时54分08秒