HarmonyOS 如何使用手机系统自带的浏览器打开url?

HarmonyOS  如何使用手机系统自带的浏览器打开url?

HarmonyOS
2024-11-01 09:14:37
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
zxjiu

module.json5文件:

"skills": [ 
{ 
  "entities": [ 
  "entity.system.home", 
  "entity.system.browsable" 
  ], 
  "actions": [ 
  "action.system.home", 
  "ohos.want.action.viewData" 
  ], 
  "uris": [ 
  { 
    "scheme": "https", 
  "host": "www.harmonyOS.com", 
  "port": "8080", 
  // prefix matching 
  "pathStartWith": "query", 
  } 
  ] 
} 
]
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.

2:index.ets文件。

import common from '@ohos.app.ability.common'; 
import Want from '@ohos.app.ability.Want'; 
import { BusinessError } from '@ohos.base'; 
 
 
let context = getContext(this) as common.UIAbilityContext; 
let wantInfo: Want = { 
 
  "action": 'ohos.want.action.viewData', 
  "entities": [ 'entity.system.browsable' ], 
  "uri": "https://www.harmonyOS.com", 
} 
 
 
 
@Entry 
@Component 
struct Index27 { 
  @State message: string = '跳转'; 
 
 
  build() { 
    Row() { 
      Column() { 
        Text(this.message) 
          .fontSize(50) 
          .fontWeight(FontWeight.Bold) 
          .onClick(async ()=>{ 
            context.startAbility(wantInfo).then(() => { 
              // ... 
            }).catch((err: BusinessError) => { 
              // ... 
            }) 
          }) 
      } 
      .width('100%') 
    } 
    .height('100%') 
  } 
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
分享
微博
QQ
微信
回复
2024-11-01 16:23:59
相关问题
HarmonyOS跳转系统浏览器打开网页报错
1862浏览 • 1回复 待解决
服务卡片webview如何跳转系统浏览器
8870浏览 • 2回复 待解决