HarmonyOS 在Page内使用方法调用方法异常
遇到一个奇怪的问题,在一个方法内调用另外一个方法,如果写this.showDialog无法调用,如果写this.showDialog(),则会抛异常:Error message:is not callableSourceCode:this.shoDialog();^
代码如下:
import { CommonButton } from '../components/CommonButton'; 
import { loadingDialog } from '../components/LoadingDialog'; 
import promptAction from '@ohos.promptAction' 
 
@Entry 
@Component 
struct Index { 
  @State message: string = 'Hello World'; 
  showDialog(){ 
    promptAction.openCustomDialog({ 
      builder: loadingDialog.bind(this,'测试中.....'), 
      isModal: false 
    }).then((dialogId: number) => { 
      this.loadingDialogId = dialogId 
    }) 
  } 
  onClickBtn() { 
    //问题点 
    this.showDialog 
  } 
 
  build() { 
    Row() { 
      CommonButton({ 
        onClickEvent: this.onClickBtn 
      }).height(48) 
        .enabled(true) 
        .width('100%') 
    } 
    .height('100%') 
  } 
 
  loadingDialogId: number = 0; 
 
}
        HarmonyOS
      
        赞
        
 收藏 0
 回答 1
 
        待解决
        
相关问题
 HarmonyOS har 模块内router 的正确使用方法 
1163浏览  • 1回复 待解决
HarmonyOS  关于AOP具体使用方法 
1720浏览  • 1回复 待解决
touchEvent的使用方法 
8056浏览  • 1回复 待解决
HarmonyOS  AsyncCallback的使用方法 
2745浏览  • 1回复 待解决
日志工具类的使用方法 
1625浏览  • 1回复 待解决
RSA 加密的具体使用方法 
1439浏览  • 1回复 待解决
HarmonyOS  自定义回调中this指向问题,无法调用Page内方法 
1021浏览  • 1回复 待解决
HarmonyOS vp的含义及使用方法? 
1054浏览  • 1回复 待解决
HarmonyOS NODE_ALIGN_SELF使用方法描述有误 
1618浏览  • 1回复 待解决
HarmonyOS .ets文件中不能使用方法重载 
1113浏览  • 1回复 待解决
#鸿蒙通关秘籍#鸿蒙栅格布局容器的使用方法 
1042浏览  • 1回复 待解决
#鸿蒙通关秘籍#KCP协议在OpenHarmony中的接口使用方法详解 
1561浏览  • 1回复 待解决
HarmonyOS  如何直接调用内部page或者组件的方法 
821浏览  • 1回复 待解决
HarmonyOS 有像 Vue 一样的插槽使用方法吗 
952浏览  • 1回复 待解决
#鸿蒙通关秘籍#HarmonyOS应用中Icon图标的使用方法 
1756浏览  • 2回复 待解决
系统日历方法使用会抛异常 
1746浏览  • 1回复 待解决
HarmonyOS  有没有具体文档介绍vp的含义及使用方法? 
1062浏览  • 1回复 待解决
HarmonyOS ComposeListItem使用switch监听onChange方法变化异常 
864浏览  • 1回复 待解决
HarmonyOS组件嵌入flutter页面 OhosView的使用方法及HarmonyOS端实现 
1457浏览  • 1回复 待解决
在应用内监听手机熄屏的方法 
2082浏览  • 1回复 待解决
ArkTs在Page页内,如何关闭当前Page页? 
4334浏览  • 1回复 待解决
使用BuilderParam在父组件调用this的方法报错:Error message:is not callable 
3084浏览  • 1回复 待解决
HarmonyOS 测试设备调用应用内支付返回异常 
1872浏览  • 1回复 待解决
HarmonyOS 单例模式打开已有page,page执行什么方法 
831浏览  • 1回复 待解决





















使用 @Builder注解,自定义方法参考链接:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/arkts-builder-V5
参考demo: