Skip to content

CreateComponent

Component utility.

Basic Usage

loading

Component Not Found Display

loading

Set Properties

loading

Set Slots

loading

Nesting

loading

Options

loading

Register Components On Demand

js
// Global registration
registerComponent({
  demo: ElInput,
});

// If only temporary use
const config = {
  component: ElInput,
};

// Function component switching mainly targets list usage. For normal use, just modify the component value directly
loading

Uniformly Set Properties

js
Registration priority: default registration in UI library < project registration < component config registration < component property registration;

registerComponentDefaultPropsMap({
  demo: {
    placeholder: 'placeholder test',
  },
});
loading

Uniformly Set Slots

js
registerComponentDefaultSlotsMap({
  demo: {
    append: 'append',
  },
});
loading

Uniformly Set Events

js
registerComponentDefaultEventsMap({
  input: {
    onClick: () => {
      console.log('click');
    },
  },
});
loading

Props

PropDescriptionTypeDefault
configComponent generation configurationConfigNone
emptyTextString displayed when component not foundStringNone

Config

PropDescriptionTypeRequired
componentRegistered component keystring | ComponentFunctionTypeYes
propsComponent properties or eventsRecord<string, any>No
childrenNested Configstring | string[] | Config[]No
slotsComponent slotsRecord<string,
string | number | VNode |
(string | number | VNode)[]>
No