以下demo是h5跳转到应用详情import web_webview from '@ohos.web.webview'; import { common, Want } from '@kit.AbilityKit'; class NaviAppStore { constructor() { } jumpAgcDetailPage() { const want: Want = { uri: `store://appgallery.huawei.com/` //uri: `store://appgallery.huawei.com/` //跳转拉起应用市场APP首页 } const context = getContext(this) as common.UIAbilityContext; context.startAbility(want).then(() => { console.log('jumpAgcDetailPage 拉起成功'); }).catch(() => { console.log('jumpAgcDetailPage 拉起失败'); }) } } @Entry @Component struct WebPage { controller: web_webview.WebviewController = new web_webview.WebviewController() @State naviApp:NaviAppStore = new NaviAppStore() build() { Row() { Column() { Web({ src: $rawfile("go_to_agc_unipay.html"), controller: this.controller }) .javaScriptProxy({ object: this.naviApp, name: "naviApp", methodList: ["jumpAgcDetailPage"], controller: this.controller }) } .width('100%') } .height('100%') } } //go_to_agc_unipay.html <!DOCTYPE html> <html> <body> <button type="button" onclick="callArkTS()">Click Me!</button> <p id="demo"></p> <script> function callArkTS() { let str = naviApp.jumpAgcDetailPage(); } </script> </body> </html>
以下demo是h5跳转到应用详情