this.$u.route跳转回来刷新
时间: 2023-06-29 18:13:30 浏览: 52
如果需要在路由跳转回来后刷新页面,可以在路由跳转时传递一个参数,在目标页面的onShow生命周期函数中判断该参数,如果存在则执行刷新操作。
示例代码如下:
在当前页面中进行路由跳转时,传递一个参数:
```
this.$u.route({
url: '/pages/target/target',
params: {
needRefresh: true
}
})
```
在目标页面的onShow生命周期函数中判断该参数,如果存在则执行刷新操作:
```
onShow() {
if (this.$options.name === 'target' && this.$route.params.needRefresh) {
// 执行刷新操作
}
}
```
这样就可以在路由跳转回来后刷新页面了。
相关问题
this.$router.push跳转页面刷新
使用this.$router.push跳转页面时,如果需要刷新页面,可以通过在App.vue组件中的router-view标签设置key值来实现。具体方法是在router-view标签中添加:key="$route.fullPath",这样当路由改变时,页面就会被刷新。另外,也可以通过监听器watch中的$route方法来实现页面刷新,具体做法是在watch中监听$route的变化,然后使用this.$router.go(0)或window.location.reload()来刷新页面。还有一种方法是在中转组件中,使用this.$router.push跳转页面之前,先调用一个方法来获取参数,在跳转时将参数作为query传递给目标页面,这样目标页面就会刷新。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [$this.router.push()更新页面](https://blog.csdn.net/weixin_45188787/article/details/124512513)[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/weixin_47800450/article/details/112167359)[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 ]
this.$route和this.$ruter区别
this.$route是Vue Router的一个实例,代表当前路由信息,包括路径、参数、查询等。可以通过它获取当前页面的路由信息。
this.$router是Vue Router的一个实例,可以通过它实现路由的跳转、导航等操作。可以通过它跳转到其他页面、刷新页面等。所以,this.$route和this.$router的区别在于,this.$route是获取当前路由信息,而this.$router是用于路由的跳转和导航。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)