vue-property-decorator
Version:
property decorators for Vue Component
17 lines (16 loc) • 450 B
JavaScript
import { createDecorator } from 'vue-class-component';
/**
* decorator of a ref prop
* @param refKey the ref key defined in template
*/
export function Ref(refKey) {
return createDecorator(function (options, key) {
options.computed = options.computed || {};
options.computed[key] = {
cache: false,
get: function () {
return this.$refs[refKey || key];
},
};
});
}