Vue框架的params和query的区别

890 阅读1分钟

this.$route.query的使用

1.传参数:
this.$router.push({
     path: '/monitor',
     query:{
     id:id,
    }
})

2.获取参数:
this.$route.query.id

3.在url中形式(url中带参数
http://172.19.186.224:8080/#/monitor?id=1

4.页面之间用路由跳转传参时,刷新跳转后传参的页面,数据还会显示存在(项目中遇到此问题)

this.$route.params的使用

1.传参数:
this.$router.push({
     name: 'monitor',
     params:{
     id:id,
    }
})

2.获取参数:
this.$route.params.id

3.在url中形式(url中不带参数)
http://172.19.186.224:8080/#/monitor

4.页面之间用路由跳转传参时,刷新跳转后传参的页面,数据不存在(项目中遇到此问题)