Answer the question
In order to leave comments, you need to log in
How to add reactive property to module injection (@nuxtjs/auth) in Nuxt?
I use Nuxt + Vuex + @nuxtjs/auth. The latter is available from the context as $auth. There is an idea to add some properties for $auth, which will return getters from the store. For example $auth.isPro. I add via plugin. The problem is that when wrapped in a function, everything works as it should, but then you have to call $auth.isPro(), which is not convenient. And when you try to make it a property, reactivity is lost. Plugin code:
import Vue from 'vue';
export default function ({ $auth, store }) {
$auth.isProFunction = () => {
return store.getters.isPro;
};
Vue.set($auth, 'isProProperty', store.getters.isPro); // Не работает, теряет реактивность
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question