vue-property-decorator
Version:
property decorators for Vue Component
18 lines (17 loc) • 567 B
JavaScript
import { createDecorator } from 'vue-class-component';
import { applyMetadata } from '../helpers/metadata';
/**
* decorator of a prop
* @param options the options for the prop
* @return PropertyDecorator | void
*/
export function Prop(options) {
if (options === void 0) { options = {}; }
return function (target, key) {
applyMetadata(options, target, key);
createDecorator(function (componentOptions, k) {
;
(componentOptions.props || (componentOptions.props = {}))[k] = options;
})(target, key);
};
}