vue之this.$route.query和this.$route.params的区别

1.this.$route.query的使用

A、传参数:

this. r o u t e r . p u s h ( p a t h : / m o n i t o r , q u e r y : i d : i d , B t h i s . router.push({ path: '/monitor', query:{ id:id, } }) B、获取参数: this. route.query.id
C、在url中形式(url中带参数)
http://172.19.186.224:8080/#/monitor?id=1
D、页面之间用路由跳转传参时,刷新跳转后传参的页面,数据还会显示存在(项目中遇到此问题)

2.this.$route.params的使用
A、传参数:

this. r o u t e r . p u s h ( n a m e : m o n i t o r , p a r a m s : i d : i d , B t h i s . router.push({ name: 'monitor', params:{ id:id, } }) B、获取参数: this. route.params.id
C、在url中形式(url中不带参数)
http://172.19.186.224:8080/#/monitor
D、页面之间用路由跳转传参时,刷新跳转后传参的页面,数据不存在(项目中遇到此问题)

猜你喜欢

转载自blog.csdn.net/weixin_43739375/article/details/89244519
今日推荐