nuxt-community / nuxt-property-decorator

Property decorators for Nuxt (base on vue-property-decorator)
https://github.com/kaorun343/vue-property-decorator
MIT License
400 stars 34 forks source link

Function in component options with context #99

Open LOUKOUKOU opened 2 years ago

LOUKOUKOU commented 2 years ago

I have a suggestion for making the options more dynamic. When you create a component using this code

const { myGetter } from 'getters-i-created'
@Component({
  computed: { myGetter }
})
export default class myComponent extends Vue {}

It would be helpful if in the component options you could pass a function, and then in that function the context could be passed via parameters. Like this:

const { myWrapper } from 'getters-wrapper-i-created'
const config = (ctx) => {
  const { myGetter, title } = myWrapper(ctx.store.state.dataForGetter)
  return {
    data: { title }
    computed: { myGetter }
  }
}

@Component(config)
export default class myComponent extends Vue {}

Kind of like composition api