@lvxiaowu/jsbridge

1.0.2 • Public • Published

H5-JSBridge

Javascript bridge android/ios webview

Install

npm install @lvxiaowu/jsbridge --save

Use

import JsBridge from '@lvxiaowu/jsbridge'

/**
 * 函数描述:js注册方法给app调用
 *
 * jsBridge.registerHandler(name, callback(data, appCallback))
 * @param {String} name 方法名
 * @param {Function} callback 回调函数
 * @param {Any} callback.data app返回的数据
 * @param {Function} callback.appCallback app返回的回调
 * @return
 */
JsBridge.registerHandler('funName', function (data, appCallback) {
  console.log(data)
}) 

/**
 * 函数描述:js调用app方法
 *
 * JsBridge.callHandler(name, params, callback)
 * @param {String} name 方法名
 * @param {Object} params 参数
 * @param {Function} callback 回调函数
 * @return
 */
JsBridge.callHandler('funName', { event: 'click' }, function (data) {
  console.log(data)
})

Dependencies (0)

    Dev Dependencies (7)

    Package Sidebar

    Install

    npm i @lvxiaowu/jsbridge

    Weekly Downloads

    1

    Version

    1.0.2

    License

    MIT

    Unpacked Size

    17.8 kB

    Total Files

    11

    Last publish

    Collaborators

    • lvxiaowu0825