跳到主要内容

createElement 创建元素

createElement

类型: MethodDeclaration

所属类: CommandFunctionList

定义位置: command.ts

描述

创建元素

参数

参数名类型描述默认值
\{operation, parent, uiId, presetId\}`{
operation: string
parent?: ElementGetter
uiId?: string
presetId?: string
}`--

返回值

类型: CommandFunction

源代码

位置: 第 4144 行

protected createElement({operation, parent, uiId, presetId}: {
operation: string
parent?: ElementGetter
uiId?: string
presetId?: string
}): CommandFunction {
switch (operation) {
case 'append-all-to-root':
return () => {
UI.root.appendChildren(UI.load(uiId!))
return true
}
case 'append-one-to-root':
return () => {
try {UI.add(presetId!)}
catch (error) {console.warn(error)}
return true
}
case 'append-all-to-element': {
const getElement = Command.compileElement(parent!)
return () => {
getElement()?.appendChildren(UI.load(uiId!))
return true
}
}
case 'append-one-to-element': {
const getElement = Command.compileElement(parent!)
return () => {
try {getElement()?.appendChild(UI.createElement(presetId!))}
catch (error) {console.warn(error)}
return true
}
}
}
throw new Error('Compiling Error')
}

文档生成时间:2025/7/7 12:07:06