当前位置:网站首页>$router和$route的区别
$router和$route的区别
2022-07-26 10:38:00 【songywaa】
$router
$router :是 VueRouter的一个对象,通过Vue.use(VueRouter)和VueRouter构造函数得到一个router的实例对象,是一个全局对象,他包含了所有的路由包含了许多关键的对象和属性;
举例:
h i s t o r y 对 象 : \color{red}{history对象:} history对象::
$router.push({
path:'home'});
//本质是向history栈中添加一个路由,在我们看来是 切换路由,但本质是在添加一个history记录
方 法 : \color{red}{方法:} 方法:
$router.replace({
path:'home'});
//替换路由,没有历史记录
$route
$route是一个跳转的路由对象,每一个路由都会有一个route对象,是一个局部的对象,可以获取对应的name,path,params,query等
我们可以从vue devtools中看到每个路由对象的不同
常用例子:
$router操作 路由跳转
this.$router.push({
name:'hello', params:{
name:'word', age:'11' } })
$route读取 路由参数接收
var name = this.$route.params.name;
边栏推荐
- 超图 影像 如何去除黑边(两种方法)
- 鹏哥C语言20210811程序结构作业
- RT-Thread 学习笔记(八)---开启基于SPI Flash的elmfat文件系统(下)
- 粽子大战 —— 猜猜谁能赢
- C language callback function
- 抽象工厂及其改进示例
- Using native JS to realize custom scroll bar (click to reach, drag to reach)
- [leetcode每日一题2021/4/23]368. 最大整除子集
- 剑指Offer(四十四):翻转单词顺序序列
- [machine learning notes] [face recognition] deeplearning ai course4 4th week programming
猜你喜欢
![[machine learning notes] [face recognition] deeplearning ai course4 4th week programming](/img/7e/9c0e88097b90c0c24ebf86f090805b.png)
[machine learning notes] [face recognition] deeplearning ai course4 4th week programming

数据分析入门 | kaggle泰坦尼克任务(一)—>数据加载和初步观察
![[notes on machine learning] [building a cyclic neural network and its application] deeplearning ai course5 1st week programming(keras)](/img/02/f85da2a2f2524fb034b17ed8d06692.png)
[notes on machine learning] [building a cyclic neural network and its application] deeplearning ai course5 1st week programming(keras)
![[leetcode每日一题2021/5/8]1723. 完成所有工作的最短时间](/img/e7/a48bb5b8a86cbc4cd5b37bb16661a8.png)
[leetcode每日一题2021/5/8]1723. 完成所有工作的最短时间

第6期:大学生应该选择哪种主流编程语言

文案秘籍七步曲至----文献团队协作管理
![[leetcode daily question 2021/4/23]368. Maximum divisible subset](/img/0b/32ca862963c842a93f79eaac94fb98.png)
[leetcode daily question 2021/4/23]368. Maximum divisible subset

英语基础句型结构------起源

Introduction to data analysis | kaggle Titanic mission (I) - > data loading and preliminary observation

Zongzi battle - guess who can win
随机推荐
What if MySQL can't get in
[leetcode每日一题2021/8/31]1109. 航班预订统计【中等】差分数组
Redis特殊数据类型使用场景
Oracle cannot start tnslistener service cannot start
MD5加密
[leetcode每日一题2021/4/29]403. 青蛙过河
13 以对象管理资源
剑指Offer(五):用两个栈实现队列
Navicat15 MySQL (centos7) connected to local virtual machine
Problems encountered in QRcode QR code (C language)
RT-Thread 学习笔记(五)---编辑、下载、调试程序
MySQL速学笔记-2021-08-31
干货likeshop外卖点餐系统开源啦100%开源无加密
.NET5WTM(ASP.NET Core) PGSql开箱操作
超图 影像 如何去除黑边(两种方法)
Uniapp uses the simple method signalr (only for web debugging, cannot package apps)
2021-08-13和鹏哥学C语言-数组
Interview questions and answers for the second company (2)
异常的概念与处理
.NET操作Redis Hash对象