Nuxt 的属性装饰器 (基于 vue-property-decorator)
Handy ES / TypeScript decorators for class-style Vue components in Nuxt (based on Vue class component) and Property decorators for Vue (bases on Vue Property Decorator) and Vuex (based on Vuex Class)
This library fully depends on vue-class-component.
MIT License
Installation is very easy
npm i -S nuxt-property-decoratoror
yarn add nuxt-property-decoratorIt works out of the box with Nuxt JS.
It works out of the box with Nuxt TS.
There are following decorators:
Nuxt specific decorators
@Off - decorator of $off@On- decorator of $on@Once- decorator of $once@NextTick -decorator of $nextTickexported from vue-class-component
@Componentexported from vue-property-decorator
exported from vuex-class
@State@Getter@Action@Mutationexported from vuex-module-decorators
Mutation from original renamed to avoid conflict with 'vuex-class' one),Action from original renamed to avoid conflict with 'vuex-class' one),namespace mixinsVuebeforeRouteEnterbeforeRouteUpdatebeforeRouteLeaveasyncDatafetchfetchOnServerheadkeylayoutloadingmiddlewarescrollToToptransitionvalidatewatchQuerymetadatabeforeCreatecreatedbeforeMountmountedbeforeDestroydestroyedbeforeUpdateupdatedactivateddeactivatedrendererrorCapturedserverPrefetch…is equivalent to
…As you can see at propA and propB, the type can be inferred automatically when it's a simple type. For more complex types like enums you do need to specify it specifically.
Also this library needs to have emitDecoratorMetadata set to true for this to work.
See also:
暂无开放 Issues,或尚未同步最近议题。