How to refresh vue-router manually when entering the page

I used this.$router.push () to jump to a page, but I didn"t get my data. I got it by refreshing it manually. I think it was refreshed manually when I first entered the page. How can I do that?

Apr.26,2022

this.$router.replace({
    path: '/refresh',
    query: {
      t: Date.now()
    }
  })

is not the right way to solve the problem. I suggest you break the debugging point.
1. Obtaining data certainly does not need an extra refresh.
2. See if the method to get the data has been called during the life cycle of the vue.


the idea of solving the problem is not correct. You can obtain data in the execution of created . If you enter route.push, you can route it under watch if you don't execute it, and then get the method that executes the data acquisition.

created(){
    //created
    this.getData()
},
methods: {
    getData(){
        //ajax
    }
},
watch: {
    //route.pushwatch
    $route(){
        this.getData()
    }
}
Menu