vue router 使用步骤
- 注册路由插件 Vue.use(VueRouter), 路由规则 routes
- 创建路由对象 new VueRouter
- 在Vue实例 配置路由对象 r o u t e 当 前 路 由 规 则 。 route当前路由规则。 route当前路由规则。router路由对象
- 路由占位 router-view
- 路由跳转 router-link
vue router 动态路由传参方式
- $route.params.id
- 在路由规则里配置 props:true,在组件里props取得相应参数
嵌套路由
- layout布局中 头与尾固定,与 中间内容 形成嵌套结构
编程式导航
- this.$route.push(’/’) 跳转后浏览器可以后退,replace不可以
- go方法 go -1 跳转至上次,go -2 跳转至上上次
hash模式与history模式
- hash模式的url。#/prams1
- history模式 ///, 依赖于后端支持
手写Vue Router
- VueRouter 的类图
options
data