一、getMatchedComponents

//vue组件生命周期中mounted() {console.log(this.$router.getMatchedComponents(),'getMatchedComponents') },
//router.js中{path: '/myRouter',name: 'myRouter',component: () => import('@/components/myCom'),children:[{path: 'third',name: 'third',component: () => import('@/components/thirdCom')},]},

输出如下,为通过路由匹配的两个组件对象(注意此处的name,并不是路由中定义的name,而是组件name)

官方文档描述如下:

二、matched

官方文档

页面访问路径为:http://localhost:8080/myRouter/third#6


//router.js
{path: '/myRouter',name: 'myRouter',component: () => import('@/components/myCom'),children:[{path: 'third',name: 'third',component: () => import('@/components/thirdCom')},]},//vue组件生命周期内mounted() {console.log(this.$route.matched,'hash')},


总结:二者的区别是,一个匹配的是组件对象,一个是路由对象

vue-router router实例方法 getMatchedComponents、matched 的使用相关推荐

  1. Vue的router配置

    新建一个router文件夹专门存放路由配置 1.main.js // 配置路由相关信息 import Vue from 'vue'; import App form './App' import ro ...

  2. 四 Vue学习 router学习

    index.js: 按需加载组件: const login = r => require.ensure([], () => r(require('@/page/login')), 'log ...

  3. 四十三、在Vue使用router,路由的管理

    @Author:Runsen @Date:2020/7/17 管理路由是一项必不可少的功能.今天,Runsen学习Vue Router. 文章目录 安装Vue Router Vue Router使用 ...

  4. vue路由-router

    VueRouter基础 vue路由的注册 导入 <script src="https://unpkg.com/vue-router/dist/vue-router.js"&g ...

  5. Vue 路由router的两种模式

    两种模式 vue中router可以设两种模式:hash和history.设置方式就是代码中注释的部分. import Vue from 'vue' import Router from 'vue-ro ...

  6. 单页vue路由router

    Vue.js + vue-router 可以很简单的实现单页应用. <router-link> 是一个组件,该组件用于设置一个导航链接,切换不同 HTML 内容. to 属性为目标地址, ...

  7. vue新版router.addRoute基础用法

    vue新版router.addRoute基础用法 新版Vue Router中用router.addRoute来替代原有的router.addRoutes来动态添加路由.子路由 在添加子路由的时候 比如 ...

  8. vue——路由router

    点击页面中的导航链接不会刷新页面,只会做页面的局部更新 1.安装vue-router 执行 npm i vue-router@3命令 注意版本 vue2--vue-router3:vue3--vue- ...

  9. vue打开二级或者三级页面传输对象,再刷新浏览器数据丢失问题解决(vue使用router传递数据)

    vue使用router进行跳转 如果只是单纯的URL跳转的话,直接指定path就可以了 this.$router.push({path:'whiteList'}}); 如果需要使用router进行单纯 ...

  10. vue路由router的props配置

    vue路由router的props配置 前置知识:vue-router3路由配置和使用,适配vue2,vue-router代码模版 路由props配置的作用:让路由组件更方便的接收到参数 ⚠️ 当不使 ...

最新文章

  1. ubuntu14.04配置java jdk
  2. python横向柱状图-python画柱状图--不同颜色并显示数值的方法
  3. 剑指offer-3 从尾到头打印链表
  4. RocketMQ大数据畅想
  5. web javascript开发 之Response.Write 与document.writ...
  6. python神经网络案例——CNN卷积神经网络实现mnist手写体识别
  7. 液晶指定位置显示 c语言,大家看看该怎么改才能让12864液晶显示屏显示21个字符啊?...
  8. 商学院计算机系篮球策划书,篮球训练营策划书.doc
  9. Manjaro linux驱动HP1020 plus打印机折腾记
  10. python3写的腾讯漫画下载器
  11. 京东商城禁止一淘网蜘蛛抓取内容
  12. 需求和设计阶段使用的IPO图
  13. 数据库 MySQL 中 DQL 数据库查询语言(特别重要)
  14. 第7章 集成方法、随机森林
  15. 海量数据预处理实战----CSS网页样式
  16. 华为 嵌入式软件工程师面试题
  17. android 密度像素,Android屏幕密度适配问题之px,dp,sp等详细介绍
  18. @staticmethod静态方法
  19. 着急上市的喜马拉雅FM,进退两难
  20. viroblast搭建blast网页

热门文章

  1. Linux权限中x是什么意思,linux里的drwxr-xr-x代表的意思
  2. 高德视觉技术中心招聘计算机视觉研发(社招/校招/实习岗位)
  3. 详解LDC架构-设计业务异地多活架构
  4. OpenStack 2015年度总结
  5. 浪潮服务器硬盘阵列怎么做,浪潮智能RAID技术为数据存储保驾护航
  6. python如何对excel批量加密_用python加密excel工作表
  7. PS学习-人像照片综合处理(二)--祛斑/祛痘与磨皮综合处理
  8. 再谈斐波那契,把数字翻译成字符串
  9. 2022-2027(新版)中国工业5G技术行业发展动态与前景规划分析报告
  10. hdu5020 Revenge of Collinearity 求三点共线的点对个数