2017年10月11日
摘要: //meta字段,一个路由匹配到的所有路由记录会暴露为 $route 对象(还有在导航守卫中的路有对象)的 $route.matched 数组。 const router = new VueRouter({ routes: [ { path: '/foo', component: Foo, children: [ { ... 阅读全文
posted @ 2017-10-11 15:23 不了无明 阅读(276) 评论(0) 推荐(0) 编辑
摘要: 导航守卫主要用来通过跳转或取消的方式守卫导航 全局守卫,使用 router.beforeEach 注册一个全局前置守卫 const router = new VueRouter({ ... }) router.beforeEach((to, from, next) => { // to: Route 阅读全文
posted @ 2017-10-11 11:49 不了无明 阅读(569) 评论(0) 推荐(0) 编辑
摘要: vue-router 默认 hash 模式,页面不会重新加载 用路由的 history 模式,利用 history.pushState API 来完成 URL 跳转而无须重新加载页面。 需要服务端支持,服务端增加一个覆盖所有情况的候选资源:如果 URL 匹配不到任何静态资源,则应该返回同一个 ind 阅读全文
posted @ 2017-10-11 10:04 不了无明 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 在组件中使用$route会使之与其对应路由形成高度耦合,使用props解耦 阅读全文
posted @ 2017-10-11 09:00 不了无明 阅读(231) 评论(0) 推荐(0) 编辑