[Vuejs]-Window.addEventListener('load', (event) => {…}); on NuxtLink (nuxt-link) or RouterLink (router-link) click

0👍

The <nuxt-link> component is similar to the <router-link> component.

In HTML5 history mode, router-link will intercept the click event so that the browser doesn’t try to reload the page. This means that onload will only be triggered when the app is first loaded.

If you need to refresh and load the page every time you link to a new route, you can do this:

window.location.href = 'your link'

By linking to the page in this way, you can find from the network panel in the browser console that every time you load a page of type text/html from the server.

Leave a comment