鸿蒙提供了这个方法 /** * Obtains the Context object associated with a component on the page. * * @param { Object } component - indicate the component on the page. * @returns { Context } * @syscap SystemCapability.ArkUI.ArkUI.Full * @StageModelOnly * @crossplatform * @since 10 */ declare function getContext(component?: Object): Context;
调用方法是在page页面获取this然后调用这个方法
context2:common.UIAbilityContext = getContext(this) as common.UIAbilityContext
window.getLastWindow(context2, (err: BusinessError, data) => {
});
这里面的data就是window