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%')
}
}
想要在工具类中弹出对话框,开发文档上有以上代码,在页面中运行以上代码,在api12中提示“"Function.bind" is not supported (arkts-no-func-bind)”,但是实际是可以执行,我想请教下为什么,除此之外我想在工具类中使用上述方式弹出对话框,注释1处的this具体是什么类型,如果是页面,那么怎么在工具类中方便的取得指向页面的this
HarmonyOS
赞
收藏 0
回答 1
待解决
相关问题
HarmonyOS 对话框弹出页面被遮挡
339浏览 • 1回复 待解决
HarmonyOS 对话框布局
70浏览 • 1回复 待解决
HarmonyOS 键盘把对话框顶上去,导致自定义对话框变形
324浏览 • 1回复 待解决
HarmonyOS class中创建对话框不能显示
282浏览 • 1回复 待解决
HarmonyOS 自定义对话框内部如何关闭该对话框?
351浏览 • 1回复 待解决
HarmonyOS 如何实现对话框可以在任何页面加载
235浏览 • 1回复 待解决
HarmonyOS如何从对话框获取用户返回结果?
603浏览 • 1回复 待解决
HarmonyOS 页面跳转后对话框不消失
325浏览 • 1回复 待解决
HarmonyOS Qt子对话框输入框无法输入文字
164浏览 • 1回复 待解决
HarmonyOS如何实现一个对话框样式的pages?
521浏览 • 1回复 待解决
HarmonyOS 如何watch viewmodel中的数据变化显示对话框
240浏览 • 1回复 待解决
HarmonyOS openCustomDialog返回的对话框id是undefined?
535浏览 • 1回复 待解决
HarmonyOS 自定义对话框自动关闭的问题
347浏览 • 1回复 待解决
HarmonyOS 自定义对话框的控制器
123浏览 • 1回复 待解决
HarmonyOS 显示的对话框如何处理返回键消失的问题
254浏览 • 1回复 待解决
HarmonyOS如何全局打开一个自定义对话框?
560浏览 • 1回复 待解决
HarmonyOS 网络请求框架中封装loading动画对话框问题
314浏览 • 1回复 待解决
HarmonyOS 修改自定义对话框的转场方式
79浏览 • 1回复 待解决
HarmonyOS 在接口中如何主动打开一个界面/对话框
307浏览 • 1回复 待解决
如何封装一个自定义Dialog对话框
2448浏览 • 1回复 待解决
HarmonyOS 文本Text组件选择对话框自定义的方案
245浏览 • 1回复 待解决
CustomDialog上面有一个textInput,点击对话框被顶出屏幕
2277浏览 • 1回复 待解决
HarmonyOS customdialogController在非组件类声明,调用open方法无法拉起对话框
620浏览 • 1回复 待解决
HarmonyOS CustomDialog 中使用 pushPathByName 跳转新页面之后页面和对话框层级问题
813浏览 • 1回复 待解决
#鸿蒙通关秘籍#如何创建和使用自定义对话框组件 TextDialog?
356浏览 • 1回复 待解决
在ArkTS中,this的语义仅限于传统的OOP风格,函数体中是禁止使用this的。该this指的是这个页面本身。此处可通过手工包装,多使用一层调用的方式解决。