Skip to content

XiaoLin1995/h5-jsbridge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

H5-JSBridge

Javascript bridge android/ios webview

Install

npm install h5-jsbridge --save

Use

import JsBridge from 'h5-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)
})

About

Javascript bridge android/ios webview

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published