vue-property-decorator
Version:
property decorators for Vue Component
17 lines (16 loc) • 481 B
JavaScript
import { createDecorator } from 'vue-class-component';
/**
* decorator of an inject
* @param from key
* @return PropertyDecorator
*/
export function Inject(options) {
return createDecorator(function (componentOptions, key) {
if (typeof componentOptions.inject === 'undefined') {
componentOptions.inject = {};
}
if (!Array.isArray(componentOptions.inject)) {
componentOptions.inject[key] = options || key;
}
});
}