中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
如何通过本地浏览器打开某个网址?
微信扫码分享
import { common, Want } from '@kit.AbilityKit'; import { BusinessError } from '@kit.BasicServicesKit'; @Entry @Component struct Index { build() { Column() { Button("").onClick(() => { const context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; startBrowsableAbility(context); }) } .height("100%") .width('100%') .justifyContent(FlexAlign.Center) } } function startBrowsableAbility(context: common.UIAbilityContext): void { let want: Want = { action: 'ohos.want.action.viewData', entities: ['entity.system.browsable'], uri: 'https://www.huawei.com/' }; context.startAbility(want) .then(() => { console.error('Start browsableAbility successfully.'); }) .catch((err: BusinessError) => { console.error(`Failed to startAbility. Code: ${err.code}, message: ${err.message}`); }); }