@smyld/vue-property-decorator
Version:
SMYLD Fork version of vue-property-decorator to port the latest version of vue-class-component
22 lines (21 loc) • 733 B
JavaScript
import { createDecorator } from 'vue-class-component';
/**
* decorator for capturings v-model binding to component
* @param options the options for the prop
*/
export function VModel(options) {
if (options === void 0) { options = {}; }
var valueKey = 'value';
return createDecorator(function (componentOptions, key) {
;
(componentOptions.props || (componentOptions.props = {}))[valueKey] = options;
(componentOptions.computed || (componentOptions.computed = {}))[key] = {
get: function () {
return this[valueKey];
},
set: function (value) {
this.$emit('input', value);
},
};
});
}