1 Star 0 Fork 0

gf/JsBridgeHarmony

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT
# JsBridge 鸿蒙版本 ----- https://github.com/guofeng007/JsBridgeHarmony ## 背景 在安卓原生app上,很多经常变更的需求或者营销活动,都是通过h5网页来实现的,而且有些功能依赖安卓原生能力,比如相机、通讯录,这个时候h5是没办法的。 JsBridge通过js和原生通讯,来解决这个问题。 本项目参考 [this](https://github.com/jacin1/JsBridge) and [lzyzsd/jsbridge](https://github.com/lzyzsd/JsBridge) and wechat jsBridge file 这个项目主要是用来在 ArkTS 和网页 JavaScript之间做通信。 ![11](https://p.ipic.vip/b2o9vu.jpg) ## ArkTS 使用 ### 添加UI组件 BridgeWebView ```typescript build() { BridgeWebView({ webUrl: $rawfile('demo.html'), controller: this.controller }) .height("100%") } ``` ### 注册Native能力 ```typescript import {JsBridge,JsCallback} from '../common/JsBridge'; JsBridge.getInstance().register("hello",(param:string,callback:JsCallback )=>{ let result = ''; if(param) { const bridgeParam = JSON.parse(param); if (bridgeParam.method) { result = bridgeParam.method; } } result +=' world'; callback(result); }) ``` ### h5通过如下方法调用端能力 ```javascript function callNativeMethod() { var param = {method:'hello',value:'world',callback:'callH5Method'}; window.jsBridge.call(JSON.stringify(param)); } ``` ## License This project is licensed under the terms of the MIT license. 开源代码地址: https://github.com/guofeng007/JsBridgeHarmony

简介

jsbridge harmony version 展开 收起
TypeScript 等 4 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/guofeng007/js-bridge-harmony.git
git@gitee.com:guofeng007/js-bridge-harmony.git
guofeng007
js-bridge-harmony
JsBridgeHarmony
master

搜索帮助