vue-router

0.Vue Router 是Vue官方的路由管理器。它和 Vue.js 的核心深度集成,让构建单页面应用变得易如反掌。vue-router 默认 hash 模式,还有一种是history模式。

hash模式的工作原理是hashchange事件,可以在window监听hash的变化。

HTML5新增的API  

history.pushState(data, title [, url]):往历史记录堆栈顶部添加一条记录; data会在onpopstate事件触发时作为   参数传递过去;

 window.onpopstate:响应pushState或replaceState的调用;

 

1.细节

实例配置对象加入属性  mode:'history'   去除 #

router.beforeEach((to,from,next) => {})  用于劫持路由跳转:to  from 表示路由的去和来 , next()  、next('/path')  控制路由跳转方向

2. 相关文章

router.beforeEach

posted @ 2019-07-29 21:27  justSmile2  阅读(151)  评论(0编辑  收藏  举报