3.2.1 • Published 7 years ago

qh-vue-property-decorator v3.2.1

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

Vue Property Decorator

This library fully depends on vue-class-component.

qh: add @NoCache

License

MIT License

Install

npm i -S vue-property-decorator

Usage

'use strict';
import { Component, prop, watch } from 'vue-property-decorator';

@Component
export class Component {
    @prop(Number)
    propA: number;

    @prop({
      type: String,
      default: 'default value'
    })
    propB: string;

    @watch('child')
    onChildChanged(val: string, oldVal: string) {}
}

is equivalent to

'use strict'
export const Component = Vue.extend({
    props: {
        propA: Number,
        propB: {
            type: String,
            required: true,
            default: ''
        }
    },
    methods: {
        onChildChanged(val, oldVal) {}
    },
    watch: {
        'child': 'onChildChanged'
    }
})