Skip to content

Tag: nuxt.js

How to use both props and mounted() with NuxtJS?

I’m new to NuxtJS and I’d want to use window.addEventListener on a particular component used on my page, but also remove the event when we change the page. In React, I’d do something like this: But, how do I do the same behaviour with NuxtJS 3? The problem is how do I remove the event once t…

How to access Nuxt context inside of fetch() hook?

I want to access the props inside the async fetch() but I’m also using async fetch(context). So, I’m not sure how to access the props. Answer In Nuxt 2, you have 2 fetch hooks. The old one, before Nuxt 2.12, fetch(context) which acts a lot like asyncData. It’s executed before the component c…