中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
如何在UI中获取Context
微信扫码分享
在页面中获取Context包含两个步骤,第一步导入依赖资源包,第二步通过getContext函数获取UIAbilityContext。
import { common } from '@kit.AbilityKit'; @Entry @Component struct Index { private context = getContext(this) as common.UIAbilityContext; // ... // 页面展示 build() { // ... } }
参考文档
UIAbility组件基本用法
在页面中获取Context包含两个步骤,第一步导入依赖资源包,第二步通过getContext函数获取UIAbilityContext。
参考文档
UIAbility组件基本用法