@click=“this.$router.go(-1)”
时间: 2024-06-04 07:10:37 浏览: 49
This is a Vue.js directive used to navigate back to the previous page in the browser history using the Vue Router. The `click` attribute specifies that the directive should trigger when the element is clicked, and the value `"this.$router.go(-1)"` is the JavaScript code that tells the router to go back one step in the history. This directive can be used on any HTML element that can be clicked, such as a button or a link.
相关问题
this.$router.go(-1) 没刷新
回答: 当使用this.$router.go(-1)返回上一页时,页面不会刷新。如果你想要刷新页面,有几种解决办法可以尝试。一种方法是使用this.$router.push来返回上一页,但前提是被push的页面不能是缓存的路由。另一种方法是监听路由的变化,在路由变化时执行相应的操作,但这种方法不被推荐使用。\[1\]另外,你也可以在beforeRouteEnter钩子函数中设置一个sessionStorage来记录上一页的路径,然后使用this.$router.push来返回上一页。\[2\]如果你只想刷新特定的页面而不是整个应用程序,你可以将该页面加入keep-alive的黑名单中。\[3\]这样,当你返回上一页时,被加入黑名单的页面将会被刷新。
#### 引用[.reference_title]
- *1* [this.$router.go(-1)页面不刷新](https://blog.csdn.net/weixin_43957384/article/details/117036499)[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^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [vue路由跳转页面不刷新、this.$router.go(-1)不生效](https://blog.csdn.net/weixin_45048913/article/details/125738459)[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^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [this.$router.go(-1)再次点击页面时数据不刷新?](https://blog.csdn.net/ccy_888/article/details/125220215)[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^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
vue this.$router.go(-1) 带参数
在Vue中,使用this.$router.go(-1)可以返回上一个页面。如果你希望在返回上一个页面的同时携带参数,可以使用eventBus或者Bus来实现。首先,在公共的bus文件(比如bus.js)中导入Vue,并创建一个实例对象。然后在当前页面中,使用Bus.$emit或eventBus.$emit来触发事件,并传递参数。在上一个页面中,监听这个事件,并在事件回调函数中获取到传递的参数。最后,使用this.$router.go(-1)返回上一个页面。这样就可以实现带参数返回上一个页面的功能。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [vue-router使用go(-1)方式进行跳转时,如何传参](https://blog.csdn.net/Caroline_Yang/article/details/104684898)[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* [vue this.$router.go(-1);返回时怎么带参数](https://blog.csdn.net/sky_sunshine_x/article/details/105482714)[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 ]
阅读全文
相关推荐
















