<div>这是首页功能</div>
};
var User = {
template: <div>这是用户功能</div>
};
var Category = {
template: <div>这是分类功能</div>
};
var router = new VueRouter({
routes: [
{ path: ‘/‘, component: Index },
{ path: ‘/user’, component: User },
{ path: ‘/category’, component: Category },
]
});
// 设置导航守卫
router.beforeEach(function (to, from, next) {
// console.log(to, from);
// next();
// next(false);
if (to.path === ‘/user’) {
next(‘/category’);
} else {
next();
}
});
var vm = new Vue({
el: ‘#app’,
router
})
</script>
</body>
</html>