鸿蒙-promptAction.showToast基于PC屏幕底部提示
app缩小,右击出弹框后,点弹框项 弹框关闭,并提示,但提示是基于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