WEB前端程序开发Web前端之路让前端飞

app中引用js方法

2019-08-23  本文已影响0人  yonglei_shang

注意:

ios webView桥接

Utility.prototype.setupWebViewJavascriptBridge = function (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)
    }

android

window.AndroidWebView[fun]
// [fun]: 为android中定义的方法
上一篇 下一篇

猜你喜欢

热点阅读