Gathering detailed insights and metrics for nuxt-property-decorator
Gathering detailed insights and metrics for nuxt-property-decorator
Gathering detailed insights and metrics for nuxt-property-decorator
Gathering detailed insights and metrics for nuxt-property-decorator
vue-property-decorator
property decorators for Vue Component
nuxt3-class-component
Nuxt3 component class decorator
bind-decorator
The fastest automatic method.bind(this) decorator
@nuxtjs/opencollective
[![npm version][npm-v-src]][npm-v-href] [![npm downloads][npm-d-src]][npm-d-href] [![status][github-actions-src]][github-actions-href]
npm install nuxt-property-decorator
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
400 Stars
144 Commits
34 Forks
12 Watching
2 Branches
43 Contributors
Updated on 25 Oct 2024
Minified
Minified + Gzipped
JavaScript (57.88%)
TypeScript (42.12%)
Cumulative downloads
Total Downloads
Last day
5.9%
4,013
Compared to previous day
Last week
5.8%
19,435
Compared to previous week
Last month
40.5%
103,392
Compared to previous month
Last year
-31.4%
1,120,890
Compared to previous year
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
1npm i -S nuxt-property-decorator
or
1yarn add nuxt-property-decorator
It 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
@Component
exported from vue-property-decorator
exported from vuex-class
@State
@Getter
@Action
@Mutation
exported 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
mixins
Vue
beforeRouteEnter
beforeRouteUpdate
beforeRouteLeave
asyncData
fetch
fetchOnServer
head
key
layout
loading
middleware
scrollToTop
transition
validate
watchQuery
meta
data
beforeCreate
created
beforeMount
mounted
beforeDestroy
destroyed
beforeUpdate
updated
activated
deactivated
render
errorCaptured
serverPrefetch
1import { 2 Component, 3 Inject, 4 Model, 5 Prop, 6 Provide, 7 Vue, 8 Watch, 9} from "nuxt-property-decorator" 10 11const s = Symbol("baz") 12 13@Component({ 14 components: { comp }, 15}) 16export class MyComponent extends Vue { 17 @Inject() foo!: string 18 @Inject("bar") bar!: string 19 @Inject(s) baz!: string 20 21 @Model("change") checked!: boolean 22 23 @Prop() 24 propA!: number 25 26 @Prop({ default: "default value" }) 27 propB!: string 28 29 @Prop([String, Boolean]) 30 propC!: string | boolean 31 32 @Prop({ type: null }) 33 propD!: any 34 35 @Provide() foo = "foo" 36 @Provide("bar") baz = "bar" 37 38 @Watch("child") 39 onChildChanged(val: string, oldVal: string) {} 40 41 @Watch("person", { immediate: true, deep: true }) 42 onPersonChanged(val: Person, oldVal: Person) {} 43 44 beforeRouteLeave(to, from, next) { 45 // called when the route that renders this component is about to 46 // be navigated away from. 47 // has access to `this` component instance. 48 } 49}
is equivalent to
1const s = Symbol("baz") 2 3export const MyComponent = Vue.extend({ 4 name: "MyComponent", 5 components: { comp }, 6 inject: { 7 foo: "foo", 8 bar: "bar", 9 [s]: s, 10 }, 11 model: { 12 prop: "checked", 13 event: "change", 14 }, 15 props: { 16 checked: Boolean, 17 propA: Number, 18 propB: { 19 type: String, 20 default: "default value", 21 }, 22 propC: [String, Boolean], 23 propD: { type: null }, 24 }, 25 data() { 26 return { 27 foo: "foo", 28 baz: "bar", 29 } 30 }, 31 provide() { 32 return { 33 foo: this.foo, 34 bar: this.baz, 35 } 36 }, 37 methods: { 38 onChildChanged(val, oldVal) {}, 39 onPersonChanged(val, oldVal) {}, 40 }, 41 beforeRouteLeave(to, from, next) { 42 // called when the route that renders this component is about to 43 // be navigated away from. 44 // has access to `this` component instance. 45 }, 46 watch: { 47 child: { 48 handler: "onChildChanged", 49 immediate: false, 50 deep: false, 51 }, 52 person: { 53 handler: "onPersonChanged", 54 immediate: true, 55 deep: true, 56 }, 57 }, 58})
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:
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 2/27 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
36 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More