#鸿蒙通关秘籍#如何启动本地PageAbility?

HarmonyOS
1天前
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
墨海涛OS

使用featureAbility中的startAbility接口可以启动本地PageAbility。启动时需要传入包含want的参数,以下为相关实现示例:

javascript import featureAbility from '@ohos.ability.featureAbility'; import Want from '@ohos.app.ability.Want'; import Logger from '../../utils/Logger';

const TAG: string = 'PagePageAbilityFirst';

(async () => { try { Logger.info(TAG, 'Begin to start ability'); let want = { bundleName: 'com.samples.famodelabilitydevelop', moduleName: 'entry', abilityName: 'com.samples.famodelabilitydevelop.PageAbilitySingleton' }; await featureAbility.startAbility({ want }); Logger.info(TAG, 'Start ability succeed'); } catch (error) { Logger.error(TAG, 'Start ability failed with ' + error); } })();

分享
微博
QQ
微信
回复
1天前
相关问题