nuxt icon indicating copy to clipboard operation
nuxt copied to clipboard

Access vuetify instance from plugin

Open tarik02 opened this issue 6 years ago • 1 comments

How can I access $vuetify from plugin? I use i18n plugin and I want to change vuetify locale when i18n's one changed:

export default function({ app }) {
  app.i18n.onLanguageSwitched = (oldLocale, newLocale) => {
    WHAT.$vuetify.lang.current = newLocale
  }
}

tarik02 avatar Dec 17 '18 18:12 tarik02

Not sure if this is the correct way but you can inject vuetify into context like this:

export default function(_, inject) {
  Vue.use(Vuetify { ...options });

  inject('vuetify', Vue.prototype.$vuetify);
};

Then use it in a plugin like:

export default function({ app }) {
  app.$vuetify.lang.current = fooBar;
}

theomjones avatar Jun 12 '19 19:06 theomjones