wetrade-design
Version:
一款多语言支持Vue3的UI框架
32 lines • 1.03 kB
JavaScript
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import { createApp, h } from 'vue';
import { COMPONENTS } from './const';
/**
* 创建vue组件
* @param param0
*/
export function useCreateVueApp(_ref) {
var key = _ref.key,
props = _ref.props,
componentKey = _ref.componentKey,
el = _ref.el,
slots = _ref.slots,
vueAppInstances = _ref.vueAppInstances,
extParam = _ref.extParam;
var component = COMPONENTS[componentKey];
if (vueAppInstances[key]) {
return;
}
vueAppInstances[key] = createApp({
render: function render() {
return h(component, _objectSpread({}, props), _objectSpread({}, slots));
}
});
vueAppInstances[key].destroy = function () {
var _vueAppInstances$key;
(_vueAppInstances$key = vueAppInstances[key]) === null || _vueAppInstances$key === void 0 ? void 0 : _vueAppInstances$key.unmount();
vueAppInstances[key] = null;
};
vueAppInstances[key].config.globalProperties.$props = extParam;
vueAppInstances[key].mount(el);
}