vue-router doesn’t provide a reload method to reload the current route. But using the $router.go() we can achieve functionality to reload the current route.
Here’s an example to reload the current route using vue-router:
<template>
<div>
<h3>About</h3>
<div>
<button @click="reloadRoute">Reload</button>
</div>
</div>
</template>
<script>
export default {
methods: {
reloadRoute() {
this.$router.go();
}
}
}
</script>
Alternatively, you can also use the window.location.reload method of Javascript to reload the current route.
<template>
<div>
<h3>About</h3>
<div>
<button @click="reloadRoute">Reload</button>
</div>
</div>
</template>
<script>
export default {
methods: {
reloadRoute() {
window.location.reload();
}
}
}
</script>
Work with our skilled Vue developers to accelerate your project and boost its performance.
Hire Vuejs Developers