Package Exports
- vue-property-decorator
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (vue-property-decorator) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Vue Property Decorator
License
MIT License
Install
npm i -S vue-property-decorator
Usage
'use strict'
import VueComponent = require('vue-class-component');
import {event, prop, watch} from 'vue-property-decorator';
@VueComponent
export class Component {
@event('some:event')
onEventReceived() {}
@prop(Number)
propA: number;
@prop({
type: String,
required: true,
default: '',
twoWay: true,
validator: (value: string) => value.length > 1,
coerce: (val: string) => val.toLowerCase()
})
propB: string;
data() {
return {
child: 'child';
};
}
@watch('child')
onChildChanged(val: string, oldVal: string) {}
}
becomes
'use strict'
export const Component = Vue.extend({
data() {
return {
child: 'child'
}
},
props: {
propA: Number,
propB: {
type: String,
required: true,
default: '',
twoWay: true,
validator: (value: string) => value.length > 1,
coerce: (val: string) => val.toLowerCase()
}
},
methods: {
onEventReceived() {},
onChildChanged() {}
}
events: {
'some:event': 'onEventReceived'
},
watch: {
'child': 'onChildChanged'
}
})