vuetifyjs / nuxt

Nuxt.js + Vuetify.js starter project template.
MIT License
306 stars 109 forks source link

Access vuetify instance from plugin #82

Open tarik02 opened 5 years ago

tarik02 commented 5 years ago

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
  }
}
theomjones commented 5 years ago

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;
}