@form-create/core
Version:
FormCreate低代码表单渲染引擎,可以通过 JSON 生成具有动态渲染、数据收集、验证和提交功能的低代码表单。支持6个UI框架,适配移动端,并且支持生成任何 Vue 组件。
38 lines (35 loc) • 1.19 kB
JavaScript
import extend from '@form-create/utils/lib/extend';
import is from '@form-create/utils/lib/type';
import {invoke, parseFn} from '../frame/util';
import toCase from '@form-create/utils/lib/tocase';
export default function useLifecycle(Handler) {
extend(Handler.prototype, {
mounted() {
const _mounted = () => {
this.isMounted = true;
this.lifecycle('mounted');
}
if (this.pageEnd) {
_mounted();
} else {
this.bus.$once('page-end', _mounted);
}
},
lifecycle(name) {
this.vm.$emit(name, this.api);
this.emitEvent(name, this.api);
},
targetReload(){
this.bus.$off('next-tick', this.nextReload);
this.bus.$once('next-tick', this.nextReload);
},
emitEvent(name, ...args) {
const _fn = this.options[name] || this.options[toCase('on-' + name)];
if (_fn) {
const fn = parseFn(_fn);
is.Function(fn) && invoke(() => fn(...args));
}
this.bus.$emit(name, ...args);
}
})
}