PC端app缩小,右击出菜单后,点菜单项 菜单关闭,并弹promptAction.showToast提示,但提示是基于PC底部弹提示的,需要的是基于app底部弹提示
原因是UIContext是右击菜单的UIContext,需要拿到菜单下面UI的UIContext,修改如下:
let promptAction: PromptAction = this.getUIContext().getPromptAction();
try {
promptAction.showToast({
message: 'Message Info',
duration: 2000
});
} catch (error) {
let message = (error as BusinessError).message;
let code = (error as BusinessError).code;
console.error(`showToast args error code is ${code}, message is ${message}`);
};
zh-cn/application-dev/reference/apis-arkui/js-apis-arkui-UIContext.md · OpenHarmony/docs - Gitee.com