import promptAction from '@ohos.promptAction'; function showToast() { promptAction.showToast({ message: '这是一个Toast消息', duration: 2000 }); } // 在需要显示Toast的地方调用showToast函数 showToast();