this.$router.push参数接收
时间: 2023-10-14 19:29:49 浏览: 104
当使用this.$router.push方法进行导航并传递参数时,可以使用query或params进行参数的接收。如果使用query方式传递参数,可以通过this.$route.query来接收参数。例如,this.$router.push({ path:'/xxx', query:{ idname:id } }),则可以通过this.$route.query.idname来获取参数。而如果使用params方式传递参数,可以通过this.$route.params来接收参数。例如,this.$router.push({ name:'路径名称', params:{ idname:id } }),则可以通过this.$route.params.idname来获取参数。需要注意的是,当传递的参数是对象或数组时,通过query方式传递在地址栏中会被强制转换成[object Object],刷新后无法获取到对象值。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [vue.js this.$router.push获取不到params参数问题](https://download.csdn.net/download/weixin_38621150/13131538)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [vue中this.$router.push()路由传值和获取的两种常见方法](https://blog.csdn.net/Vivien_CC/article/details/126880417)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文