跳到主要内容

getObjectProperty 获取对象变量

getObjectProperty

类型: MethodDeclaration

所属类: CommandFunctionList

定义位置: command.ts

描述

获取对象变量

参数

参数名类型描述默认值
\{ variable, saveVariable, properties, \}{
	variable: [`VariableGetter`](https://github.com/Open-Yami-Community/open-yami-doc/blob/main/i18n/zh/docusaurus-plugin-content-docs/current/script/yami/yami.command.d.ts#L87);
saveVariable: [`VariableGetter`](https://github.com/Open-Yami-Community/open-yami-doc/blob/main/i18n/zh/docusaurus-plugin-content-docs/current/script/yami/yami.command.d.ts#L87);
properties: Array<any>;
} | - | - |

返回值

类型: CommandFunction

源代码

位置: 第 2943 行

protected getObjectProperty({
variable,
saveVariable,
properties,
}: {
variable: VariableGetter;
saveVariable: VariableGetter;
properties: Array<any>;
}): CommandFunction {
const getter = Command.compileVariable(variable, Attribute.GET);
const setter = Command.compileVariable(saveVariable, Attribute.SET);
return () => {
const object = getter();
if (object !== undefined) {
const value = properties.reduce(
(object, property) => object[property.text],
object
);
setter(value);
}
return true;
};
}

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