百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
N

nuxt-property-decorator

> 前端框架
开源

Nuxt 的属性装饰器 (基于 vue-property-decorator)

397 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

Nuxt 的属性装饰器 (基于 vue-property-decorator)

Nuxt 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.

License

MIT License

Install

Installation is very easy

bash
npm i -S nuxt-property-decorator

or

bash
yarn add nuxt-property-decorator

Nuxt JS Instructions

It works out of the box with Nuxt JS.

Nuxt TS Instructions

It works out of the box with Nuxt TS.

Decorators and helpers

There are following decorators:

  • Nuxt specific decorators

    • @Off - decorator of $off
    • @On- decorator of $on
    • @Once- decorator of $once
    • @NextTick -decorator of $nextTick
  • exported from vue-class-component

    • @Component
  • exported from vue-property-decorator

    • @Emit
    • @Inject
    • @InjectReactive
    • @Model
    • @ModelSync
    • @Prop
    • @PropSync
    • @Provide
    • @ProvideReactive
    • @Ref
    • @VModel
    • @Watch
  • exported from vuex-class

    • @State
    • @Getter
    • @Action
    • @Mutation
  • exported from vuex-module-decorators

    • Module,
    • getModule,
    • VuexModule,
    • VuexMutation (Mutation from original renamed to avoid conflict with 'vuex-class' one),
    • MutationAction,
    • VuexAction (Action from original renamed to avoid conflict with 'vuex-class' one),

Other exports

  • namespace
  • mixins
  • Vue

Hooks

Vue Router hooks

  • beforeRouteEnter
  • beforeRouteUpdate
  • beforeRouteLeave

Nuxt hooks

  • asyncData
  • fetch
  • fetchOnServer
  • head
  • key
  • layout
  • loading
  • middleware
  • scrollToTop
  • transition
  • validate
  • watchQuery
  • meta

Vue-class Hooks

  • data
  • beforeCreate
  • created
  • beforeMount
  • mounted
  • beforeDestroy
  • destroyed
  • beforeUpdate
  • updated
  • activated
  • deactivated
  • render
  • errorCaptured
  • serverPrefetch

Usage

…

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.

Useful links

See also:

  • Vue Property Decorator
  • Vue class component
  • Vuex Class
  • Nuxt Class Component

Issues· 15 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

JavaScriptnuxtnuxt-decoratorsvuevue-decorators

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类前端框架
定价开源

> 相关工具

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架