3

I would like to write a getter to return this.$nuxt.$loading from a vuex store file. (https://nuxtjs.org/api/configuration-loading/)

This question is linked to my other question: Nuxt/Vue: How to position custom loading component

And now I thought of listening to this loading property to display my Loading component within the page.

The Loading property looks like this:

enter image description here

So I would like to return this.$nuxt.$loading.data.$route.show from the vuex store. If it is true, I want to show my custom loader and if its false not – of course.

To do that I would like to access this.$nuxt but this is undefined in my vuex store. It is only present in my components... I tried $nuxt – same result.

I don't know if this is right or at least one way to achieve what I want, and I am definitely open for suggestions.

Thanks in advance. Cheers

2 Answers 2

5

You can use window.$nuxt for this.

Sign up to request clarification or add additional context in comments.

2 Comments

I get ERROR window is not defined
Sorry, should've mentioned this doesn't work when using SSR.
1

I used this._vm.

You can see it in there if you do console.log(this) in Vuex.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.