HarmonyOS 点击webview页面的按钮,无法跳转到app应用的钱包页面?

1、用的uniapp框架开发的app,转成了HarmonyOSapp应用。

2、app应用通过webview嵌入了H5页面,点击H5页面的按钮,跳转app应用指定页面。目前是点击H5页面的按钮,无法跳转到app应用的钱包页面。

3、H5跳转app页面的代码如下所示:

// 注入uniappjs重定向到app
import * as uni from './common/uni_webview.js'

document.addEventListener("UniAppJSBridgeReady", function () {
  Vue.prototype.myUni = uni
});
this.myUni.webView.navigateTo({
  url: `${url}?ac=11122`
})
阅读 517
1 个回答

无法直接跳转,可以使用以下两种方式:

1、可以web拦截后拉起,参考以下demo:

Web({ src: $rawfile('call.html'), controller: this.controller })
  .onLoadIntercept((event) => {
    if (event) {
      let url: string = event.data.getRequestUrl();
      if (url.indexOf('appScheme://') === 0) {
        const want: Want = {
          uri: `store://appgallery.huawei.com/app`
        }
        const context = getContext(this) as common.UIAbilityContext;
        context.startAbility(want).then(() => {
        }).catch(() => {
        })
        return true;
      }
    }
    return false;
  })

2、当前是支持Deep Link的,参考:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/deep-linking-startup-V5