1# API切换概述 2 3 4FA模型和Stage模型由于线程模型和进程模型的差异,部分接口仅在FA模型下才能使用,针对这部分接口在SDK的接口中有FAModelOnly的标记,用于提醒开发者这部分接口仅能在FA模型下使用。因此在切换到Stage模型时,需要将应用中用到的FAModelOnly接口替换成Stage模型下对应的接口。下面是startAbility的接口切换示例,全量接口列表请查看后续章节: 5 6 7 8startAbility接口由FA模型切换到Stage模型的示例: 9 10- FA模型示例 11 12 ```ts 13 import fa from '@ohos.ability.featureAbility'; 14 import { BusinessError } from '@ohos.base'; 15 16 fa.startAbility({ 17 "want": { 18 bundleName: "com.example.myapplication", 19 abilityName: "com.example.myapplication.EntryAbility" 20 } 21 }).then((data) => { 22 console.info('startAbility success'); 23 }).catch((error: BusinessError) => { 24 console.error('startAbility failed.'); 25 }) 26 ``` 27 28- Stage示例示例 29 30 ```ts 31 import Want from '@ohos.app.ability.Want'; 32 33 // context为Ability对象的成员,在非Ability对象内部调用需要 34 // 将Context对象传递过去 35 let wantInfo: Want = { 36 bundleName: "com.example.myapplication", 37 abilityName: "EntryAbility" 38 }; 39 this.context.startAbility(wantInfo).then(() => { 40 console.info('startAbility success.'); 41 }).catch((error: BusinessError) => { 42 console.error('startAbility failed.'); 43 }) 44 ``` 45