HarmonyOS Web开发,能否添加多个javaScriptProxy,验证发现不可以。能否支持?

HarmonyOS Web开发,能否添加多个javaScriptProxy,验证发现不可以。能否支持?

HarmonyOS
2024-11-06 10:47:17
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
zxjiu

​javaScriptProxy只支持注入一个JavaScript对象,如果要注册多个对象,请使用registerJavaScriptProxy。registerJavaScriptProxy使用指导:​https://developer.huawei.com/consumer/cn/doc/harmonyos-references/js-apis-webview-V5#registerjavascriptproxy

例如可以在onControllerAttached中调用:​

Web({ src:'www.xhuawei.com', controller: this.webviewController }) 
  .onControllerAttached(() => { 
    try { 
      this.webviewController.registerJavaScriptProxy(this.testObjtest1, 'JSBridge1', ['toString','test']); 
      this.webviewController.registerJavaScriptProxy(this.testObjtest2, 'JSBridge2', ['test','toString']); 
    } catch (err) { 
      console.error(`Invoke webviewController.registerJavaScriptProxy failed! err: ${JSON.stringify(err)}`); 
    } 
  })
分享
微博
QQ
微信
回复
2024-11-06 15:20:04
相关问题
zxing能否支持添加中心图标
1300浏览 • 1回复 待解决
图片编辑-如何添加多个贴纸功能
364浏览 • 0回复 待解决
nova5系为啥不可以申请
6793浏览 • 1回复 待解决
动态申请权限能否添加描述
990浏览 • 1回复 待解决
HarmonyOS sendable能否支持pixelmap类型
231浏览 • 1回复 待解决
CustomDialogController能否支持再次封装
892浏览 • 1回复 待解决
ArkUI组件能否支持继承
1728浏览 • 1回复 待解决