How to use vue-router's router-link to refresh the current route

When I was working on the project, I wrote a part of the code with Vue, and I wanted to use router-link to implement routing jumps, and then refresh the page on the current page.

<router-link  to="/someWhere" @click.native="refresh">
    <button>按钮</button>
</router-link> 
<script>
export default {
  ...
  ...
  methods:{
    refresh:function(){
      this.$router.go(0);  
    }
  }
}
</script>

router is a routing instance, for example: var router = new Router({})
router.go(n) is a method of routing, which means how many steps forward or backward in the history record, 0 means it is still current, similar to window.history .go(n)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324463583&siteId=291194637