即时反馈
分成两种
DEFAULT
TOP_MOST
区别
简单来说一句话:
当页面有表单的时候需要使用软键盘
- DEFAULT: 以 UIExtension 为主窗中布局,对齐方式与 UIExtension 对齐
- TOP_MOST: 以宿主窗口为主窗中布局,对齐方式与宿主窗口对齐。
一般 default 就可以了
代码
ts
import { promptAction } from '@kit.ArkUI';
@Entry
@Component
struct Index {
build() {
Column({ space: 10 }) {
TextInput()
Button() {
Text("DEFAULT类型Toast")
.fontSize(20)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.onClick(() => {
promptAction.showToast({
message: "ok,我是DEFAULT toast",
textColor: "red",
duration: 2000,
bottom: 80
})
})
Button() {
Text("TOPMOST类型Toast")
.fontSize(20)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.onClick(() => {
promptAction.showToast({
message: "ok,我是TOP_MOST toast",
textColor: "red",
duration: 2000,
showMode: promptAction.ToastShowMode.TOP_MOST,
bottom: 85
})
})
}.height('100%')
}
}