1.0.6-1 • Published 3 years ago

native-jsbridge v1.0.6-1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

native-jsbridge

用于H5和native之间通信的JS插件,支持Typescript

Native需要集成的配套插件

  1. IOS(UIWebview): https://github.com/marcuswestin/WebViewJavascriptBridge
  2. IOS(WKWebview): https://github.com/Lision/WKWebViewJavascriptBridge
  3. Android: https://github.com/lzyzsd/JsBridge

安装

使用npm安装:

npm install native-jsbridge --save-dev

使用

  1. js调用原生方法
import { callNative } from "native-jsbridge";

callNative({
    method: "exampleMethod",
    data: { id: 5 },
    callback(response){
        console.log("来源于原生的反馈信息: " + response);
    }
})
  1. 原生调用JS方法
import { bridgeRegisterHandler } from "native-jsbridge";

bridgeRegisterHandler({
    method: "exampleMethod",
    data: {option: 'xxxxx'}, // 原生那边回调可以拿到的参数数据
    callback(data){
        console.log("原生传递给前端的data: " + data);
    }
})
1.0.6-1

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago