在HarmonyOS NEXT开发中BaseAbility extends UIAbility:Cannot find name 'Context'?

在HarmonyOS NEXT开发中BaseAbility extends UIAbility:Cannot find name 'Context'?

阅读 536
1 个回答

具体如下所示:

export default abstract class BaseAbility extends UIAbility { 
 
  static appContext:common.ApplicationContext; 
 
  onWindowStageCreate(windowStage: window.WindowStage): void { 
    BaseAbility.appContext = this.context.getApplicationContext() 
    Logger.info('testTag', '%{public}s', 'BaseAbility onWindowStageCreate'); 
    super.onWindowStageCreate(windowStage) 
  } 
 
  static getContext(): common.ApplicationContext { 
    return BaseAbility.appContext; 
  } 
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题