前端js 与 ios 相互之间调用

/*这段代码是固定的,必须要放到js中*/
function setupWebViewJavascriptBridge(callback) {
    if (window.WebViewJavascriptBridge) { return callback(WebViewJavascriptBridge); }
    if (window.WVJBCallbacks) { return window.WVJBCallbacks.push(callback); }
    window.WVJBCallbacks = [callback];
    var WVJBIframe = document.createElement('iframe');
    WVJBIframe.style.display = 'none';
    WVJBIframe.src = 'wvjbscheme://__BRIDGE_LOADED__';
    document.documentElement.appendChild(WVJBIframe);
    setTimeout(function () { document.documentElement.removeChild(WVJBIframe) }, 0)
}

/*与OC交互的所有JS方法都要放在此处注册,才能调用通过JS调用OC或者让OC调用这里的JS*/
setupWebViewJavascriptBridge(function (bridge) {
    bridge.registerHandler('editAreaInfo', function (data,responseCallback) {
    })
})

 setupWebViewJavascriptBridge(function (bridge) {
                       bridge.callHandler('nodeTap', jsonStr, function(response) {
                     })
   })

/*安卓*/

Android.clickChart(jsonStr);

你可能感兴趣的:(js)