跳到主要内容

nestElement 嵌套元素

nestElement

类型: MethodDeclaration

所属类: CommandFunctionList

定义位置: command.ts

描述

嵌套元素

参数

参数名类型描述默认值
\{ parent, child, \}{
	parent: [`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);
child: [`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

源代码

位置: 第 5439 行

protected nestElement({
parent,
child,
}: {
parent: ElementGetter;
child: ElementGetter;
}): CommandFunction {
const getParent = Command.compileElement(parent);
const getChild = Command.compileElement(child);
return () => {
const parent = getParent();
const child = getChild();
if (parent && child && parent !== child) {
child.remove();
parent.appendChild(child);
}
return true;
};
}

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