
Security News
Opengrep Adds Apex Support and New Rule Controls in Latest Updates
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.
nuxt-property-decorator
Advanced tools
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-decorator
or
yarn 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 $nextTick
exported 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
import {
Component,
Inject,
Model,
Prop,
Provide,
Vue,
Watch,
} from "nuxt-property-decorator"
const s = Symbol("baz")
@Component({
components: { comp },
})
export class MyComponent extends Vue {
@Inject() foo!: string
@Inject("bar") bar!: string
@Inject(s) baz!: string
@Model("change") checked!: boolean
@Prop()
propA!: number
@Prop({ default: "default value" })
propB!: string
@Prop([String, Boolean])
propC!: string | boolean
@Prop({ type: null })
propD!: any
@Provide() foo = "foo"
@Provide("bar") baz = "bar"
@Watch("child")
onChildChanged(val: string, oldVal: string) {}
@Watch("person", { immediate: true, deep: true })
onPersonChanged(val: Person, oldVal: Person) {}
beforeRouteLeave(to, from, next) {
// called when the route that renders this component is about to
// be navigated away from.
// has access to `this` component instance.
}
}
is equivalent to
const s = Symbol("baz")
export const MyComponent = Vue.extend({
name: "MyComponent",
components: { comp },
inject: {
foo: "foo",
bar: "bar",
[s]: s,
},
model: {
prop: "checked",
event: "change",
},
props: {
checked: Boolean,
propA: Number,
propB: {
type: String,
default: "default value",
},
propC: [String, Boolean],
propD: { type: null },
},
data() {
return {
foo: "foo",
baz: "bar",
}
},
provide() {
return {
foo: this.foo,
bar: this.baz,
}
},
methods: {
onChildChanged(val, oldVal) {},
onPersonChanged(val, oldVal) {},
},
beforeRouteLeave(to, from, next) {
// called when the route that renders this component is about to
// be navigated away from.
// has access to `this` component instance.
},
watch: {
child: {
handler: "onChildChanged",
immediate: false,
deep: false,
},
person: {
handler: "onPersonChanged",
immediate: true,
deep: true,
},
},
})
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:
FAQs
Property decorators for Nuxt
The npm package nuxt-property-decorator receives a total of 8,274 weekly downloads. As such, nuxt-property-decorator popularity was classified as popular.
We found that nuxt-property-decorator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.