element-plus-jsx
Version:
基于 Element Plus 扩展 JSX 语法的组件库
53 lines (50 loc) • 1.16 kB
JavaScript
import { defineComponent, useSlots, toRefs, reactive, getCurrentInstance, provide, renderSlot } from 'vue';
import { providerInjectKey } from './context.js';
var _sfc_main = /*@__PURE__*/defineComponent({
__name: 'providerx',
props: {
tableProps: {
type: Object,
required: false
},
formProps: {
type: null,
required: false
},
tablePlugins: {
type: Array,
required: false
},
formPlugins: {
type: Array,
required: false
}
},
setup(__props) {
const props = __props;
const slots = useSlots();
const {
tableProps,
formProps,
tablePlugins,
formPlugins
} = toRefs(props);
const contextConfig = reactive({
slots,
tableProps,
formProps,
tablePlugins,
formPlugins
});
const instance = getCurrentInstance();
if (instance) {
instance.appContext.app.provide(providerInjectKey, contextConfig);
} else {
provide(providerInjectKey, contextConfig);
}
return (_ctx, _cache) => {
return renderSlot(_ctx.$slots, "default");
};
}
});
export { _sfc_main as default };