#鸿蒙学习大百科#如何通过本地浏览器打开某个网址?

如何通过本地浏览器打开某个网址?

HarmonyOS
2024-10-26 11:22:48
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
海底捞天王
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}`);
    });
}
分享
微博
QQ
微信
回复
2024-10-26 16:20:02
相关问题
#鸿蒙学习大百科#模拟如何抓包?
288浏览 • 1回复 待解决