One solution to re-render a page when clicking on the same page's navigation link is to use the beforeRouteUpdate hook in Vue.js. This hook is called when the route is updated but the component is reused.
Here's an example of how to use the beforeRouteUpdate hook to re-render the component:
export default {
data() {
return {
key: 0
};
},
beforeRouteUpdate(to, from, next) {
// Update the key to force a re-render
this.key++;
next();
}
}
In this example, we're using a key property to force a re-render of the component. When the beforeRouteUpdate hook is called, we increment the key property to trigger a re-render.
Then, in the template, we can use the key property to force a re-render of the component:
<template>
<div :key="key">
<!-- Component content here -->
</div>
</template>
By using the key property in the template, Vue.js will re-render the component whenever the key property changes.