博客
关于我
vue路由6:导航钩子
阅读量:308 次
发布时间:2019-03-04

本文共 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})

转载地址:http://jgvq.baihongyu.com/

你可能感兴趣的文章
centos 文件格式不对执行报错 || centos查看或者修改文件格式
查看>>
win锁屏界面用户名修改
查看>>
Java设计模式 —— 桥接模式(Bridge)
查看>>
计算机三级 信息安全技术历年真题(二)总共十套 3月底之前更完
查看>>
详解: 最小生成树
查看>>
[编程题]:n头牛中选择满足所有m种特性的牛(百度2021)
查看>>
Redis中的删除策略和逐出算法
查看>>
[数据结构]:红黑树(二)
查看>>
PyCharm安装与配置
查看>>
Docker - 部署 Redis 6.0.8
查看>>
Android - Create dynamic lists with RecyclerView
查看>>
Android - Broadcasts overview(不完整)
查看>>
Spring Boot - Add a Servlet to an Application
查看>>
OrCAD Capture CIS 16.6 - 为元器件添加属性
查看>>
Web API - File - Selecting files using drag and drop
查看>>
Spring Boot - axios upload file(带请求头上传文件,非前后端分离)
查看>>
排序算法总结——c++实现
查看>>
STL基础梳理 2019.1.19(仿函数,谓词,内建函数对象,适配器,算法)
查看>>
IDEA效率快捷键收集
查看>>
并发情况下三种线程/并发安全
查看>>