跳到主要内容

deleteElement 删除元素

deleteElement

类型: MethodDeclaration

所属类: CommandFunctionList

定义位置: command.ts

描述

删除元素

参数

参数名类型描述默认值
\{ operation, element, \}{
	operation: string;
element: [`ElementGetter`](https://github.com/Open-Yami-Community/open-yami-doc/blob/main/i18n/zh/docusaurus-plugin-content-docs/current/script/yami/yami.command.d.ts#L438);
} | - | - |

返回值

类型: CommandFunction

源代码

位置: 第 5518 行

protected deleteElement({
operation,
element,
}: {
operation: string;
element: ElementGetter;
}): CommandFunction {
switch (operation) {
case "delete-element": {
const getElement = Command.compileElement(element);
return () => {
getElement()?.destroy();
return true;
};
}
case "delete-children": {
const getElement = Command.compileElement(element);
return () => {
getElement()?.clear();
return true;
};
}
case "delete-all":
return () => {
UI.reset();
return true;
};
}
throw new Error("Compiling Error");
}

文档生成时间:2026/2/1 16:51:39