'get 'this' in nuxt plugin?

So you can create a plugin in nuxt like this:

const utils = {
  name: utils,
  emmitModel(name, val) {
    const value = Object.assign({}, this.value)
    value[name] = val
    this.$emit('input', value)
  },
}

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

However, in the above, 'this' is not defined. How do I access the 'this' component context inside emmitModel?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source