HarmonyOS 弹出对话框
import promptAction from '@ohos.promptAction'
let customDialogId: number = 0
@Builder
function customDialogBuilder() {
Column() {
Text('Custom dialog Message').fontSize(10)
Row() {
Button("确认").onClick(() => {
promptAction.closeCustomDialog(customDialogId)
})
Blank().width(50)
Button("取消").onClick(() => {
promptAction.closeCustomDialog(customDialogId)
})
}
}.height(200).padding(5)
}
@Entry
@Component
struct Index {
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
.onClick(() => {
promptAction.openCustomDialog({
builder: customDialogBuilder.bind(this)//1,此this是什么类型,在非页面中怎么获得指向页面的this
}).then((dialogId: number) => {
customDialogId = dialogId
})
})
}
.width('100%')
}
.height('100%')
}
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
- 36.
- 37.
- 38.
- 39.
- 40.
- 41.
- 42.
想要在工具类中弹出对话框,开发文档上有以上代码,在页面中运行以上代码,在api12中提示“"Function.bind" is not supported (arkts-no-func-bind)”,但是实际是可以执行,我想请教下为什么,除此之外我想在工具类中使用上述方式弹出对话框,注释1处的this具体是什么类型,如果是页面,那么怎么在工具类中方便的取得指向页面的this
HarmonyOS
赞
收藏 0
回答 1
相关问题
HarmonyOS 对话框弹出页面被遮挡
992浏览 • 1回复 待解决
HarmonyOS 对话框布局
596浏览 • 1回复 待解决
HarmonyOS 键盘把对话框顶上去,导致自定义对话框变形
1006浏览 • 1回复 待解决
HarmonyOS class中创建对话框不能显示
807浏览 • 1回复 待解决
HarmonyOS 自定义对话框内部如何关闭该对话框?
908浏览 • 1回复 待解决
HarmonyOS如何从对话框获取用户返回结果?
1200浏览 • 1回复 待解决
HarmonyOS 如何实现对话框可以在任何页面加载
731浏览 • 1回复 待解决
HarmonyOS 页面跳转后对话框不消失
899浏览 • 1回复 待解决
HarmonyOS Qt子对话框输入框无法输入文字
699浏览 • 1回复 待解决
HarmonyOS 如何watch viewmodel中的数据变化显示对话框
730浏览 • 1回复 待解决
HarmonyOS如何实现一个对话框样式的pages?
1032浏览 • 1回复 待解决
HarmonyOS openCustomDialog返回的对话框id是undefined?
998浏览 • 1回复 待解决
HarmonyOS 自定义对话框自动关闭的问题
840浏览 • 1回复 待解决
HarmonyOS 自定义对话框的控制器
591浏览 • 1回复 待解决
HarmonyOS 显示的对话框如何处理返回键消失的问题
844浏览 • 1回复 待解决
HarmonyOS如何全局打开一个自定义对话框?
1081浏览 • 1回复 待解决
HarmonyOS 网络请求框架中封装loading动画对话框问题
1016浏览 • 1回复 待解决
HarmonyOS 修改自定义对话框的转场方式
595浏览 • 1回复 待解决
HarmonyOS 在接口中如何主动打开一个界面/对话框
764浏览 • 1回复 待解决
如何封装一个自定义Dialog对话框
3058浏览 • 1回复 待解决
HarmonyOS 文本Text组件选择对话框自定义的方案
838浏览 • 1回复 待解决
HarmonyOS customdialogController在非组件类声明,调用open方法无法拉起对话框
1202浏览 • 1回复 待解决
CustomDialog上面有一个textInput,点击对话框被顶出屏幕
2806浏览 • 1回复 待解决
HarmonyOS CustomDialog 中使用 pushPathByName 跳转新页面之后页面和对话框层级问题
1311浏览 • 1回复 待解决
HarmonyOS打开对话框时如何实现从下到上出现的动画?
1374浏览 • 1回复 待解决
在ArkTS中,this的语义仅限于传统的OOP风格,函数体中是禁止使用this的。该this指的是这个页面本身。此处可通过手工包装,多使用一层调用的方式解决。