HarmonyOS 原生与js交互

JavascriptInterface 被调用的方法,怎么可以控制UI里的变化。

.javaScriptProxy({ 
  object: this.javascriptInterface, 
  name: "App", 
  methodList: ["isApp", "showBar", "hideBar", "toString"], 
  controller: this.controller 
}) 
 
class JavascriptInterface { 
 
  isApp(): string { 
    return 'SuperDeer_Harmony'; 
  } 
 
  showBar() { 
    this.statusBarHeight = SWindowUtils.statusBarHeight 
  } 
 
  hideBar() { 
    this.statusBarHeight = 0 
  } 
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
HarmonyOS
2024-11-07 11:11:12
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
Heiang

可以在JavascriptInterface类中新增属性,在UI中直接使用属性值,当@State修饰的数据类型是对象的时候,可以观察到其属性值的变化。

分享
微博
QQ
微信
回复
2024-11-07 14:59:18
相关问题
HarmonyOS Web js原生交互
1253浏览 • 1回复 待解决
HarmonyOS WebViewjs交互
842浏览 • 1回复 待解决
HarmonyOS webview原生交互方法重名
676浏览 • 1回复 待解决
ArkTS/js怎样C++进行交互
1364浏览 • 1回复 待解决
HarmonyOS web端原生交互
650浏览 • 1回复 待解决
如何桥接鸿蒙原生H5之间的交互
666浏览 • 2回复 已解决
HarmonyOS H5和原生交互
974浏览 • 1回复 待解决
HarmonyOS web和js交互
730浏览 • 1回复 待解决
HarmonyOS web和原生交互的demo
614浏览 • 1回复 待解决
HarmonyOS webview原生通信
1001浏览 • 1回复 待解决
HarmonyOS WebJavaScript交互
921浏览 • 1回复 待解决
HarmonyOS webview和JS进行交互
749浏览 • 1回复 待解决
HarmonyOS web组件和js交互
794浏览 • 1回复 待解决
HarmonyOS webview加载交互
801浏览 • 1回复 待解决
HarmonyOS 系统web交互
634浏览 • 1回复 待解决
HarmonyOS web原生和H5如何交互
1501浏览 • 1回复 待解决
HarmonyOS RN如何Native交互
838浏览 • 1回复 待解决