本文共 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/