[Vuejs]-Get 'this' in nuxt plugin?

3👍

Assuming this references your Vue instance, wrap your utils object in a Vue instance, like so:

const utils = new Vue({
  // ..stuff here
})

export default ({ app }, inject) => {
  inject('utils', utils)
}

And then within the Vue object you can fully use component methods, computed, data, and access the VM and utils will be injected in nuxt as this.$utils

Leave a comment