router.push的区别:
使用push方法的跳转会向 history 栈添加一个新的记录,当我们点击浏览器的返回按钮时可以看到之前的页面。 使用replace方法不会向 history 添加新记录,而是替换掉当前的 history 记录,即当replace跳转到的网页后,‘后退’按钮不能查看之前的页面。
route,它是一条路由
- { path: '/home', component: Home }
routes,是一组路由。
const routes = [
- { path: '/home', component: Home },
- { path: '/about', component: About } ]
router
可以理解为一个容器,或者说一种机制,它管理了一组route。简单来说,route只是进行了URL和函数的映射,而在当接收到一个URL之后,去路由映射表中查找相应的函数,这个过程是由router来处理的。
const router = new VueRouter({
routes // routes: routes 的简写
})