vue-router
vue-router通过 hash 与 History interfac e两种方式实现前端路由,更新视图但不重新请求页面”是前端路由原理的核心之一,目前在浏览器环境中这一功能的实现主要有两种方式 hash ---- 利用URL中的hash(“#”) 利用 History interface在 HTML5中新增的方法;History.pushState() 那么,我们要选择用哪种方式呢? 在vue-router中,它提供mode参数来决定采用哪一种方式,选择流程如下: mode 参数: let routes = [{ path:'/', redirect:'/index', meta:{title:'index',keepLive:true} }, { path:'/index', component:require('./views/index.vue'), meta:{title:'index',keepLive:true} } ] let router = new Router({ mode:'hash', routes:routes }) 默认hash history 注:如果浏览器不支持history新特性,则采用hash方式 如果不在浏览器环境则使用abstract(node环境下) 来源: oschina 链接: https://my.oschina.net