After vue3 uses router.push() to jump to the page, the page does not refresh.

Article directory

Cause Analysis

This is a common problem. When using push, a new record will be added to the history stack. At this time, when the exact same route is added, it will not be refreshed again.

optimal solution

Add params parameter time when page jumps

router.push({
    
    
   path: '/index',
   query: {
    
    
     date: new Date().getTime(),
   },
 })

In the page that jumps to, add watch monitoring

import {
    
     watch } from 'vue'
import {
    
     useRoute, useRouter } from 'vue-router'
const route = useRoute()
watch(route, (to, from) => {
    
    
  router.go(0)
})

perfect solution

Guess you like

Origin blog.csdn.net/wang13679201813/article/details/133087715