zoukankan      html  css  js  c++  java
  • h5页与ios通信

    直接上代码 1 粘第一段

    //ios
    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)
    }
    setupWebViewJavascriptBridge(function(bridge) {
        iapp.sidebar.delegate("li","touchend",function(event){
            var $this = $(this);
            var index = $this.index();
            var point = {
                0:function(){
                    bridge.callHandler('CallHandlerID', {'key': '患者'}, function(response){
                           
                    })
                },
                1:function(){
                    bridge.callHandler('CallHandlerID', {'key': '疾病'}, function(response){
                           
                    })
                },
                2:function(){
                    bridge.callHandler('CallHandlerID', {'key': '检测史'}, function(response){
                           
                    })
                },
                3:function(){
                    bridge.callHandler('CallHandlerID', {'key': '家族史'}, function(response){
                           
                    })
                },
                4:function(){
                     bridge.callHandler('CallHandlerID', {'key': '用药史'}, function(response){
                           
                    })
                }
    
            }
    
            point[index]();
            
        })
     })

    需求还是挺简单的 点击了那个菜单就穿那个菜单名过去

    https://github.com/marcuswestin/WebViewJavascriptBridge

  • 相关阅读:
    jenkins
    Nexus5安装PostmarketOS(Alpine Linux)并装上Docker
    Abp Abp.AspNetZeroCore 2.0.0 2.1.1 Path
    音速启动 Vstart 5.7 win10手动移除后台设置主页
    Win10 20h2 19041 任务管理器 性能 蓝屏
    PostMan 在请求中自动添加Header
    LINQPad_6.9.15_Premium
    Byd 字段清单 通过JS端点导入
    SAP B1 修改数据库中b1版本号
    event是啥
  • 原文地址:https://www.cnblogs.com/junwu/p/6365617.html
Copyright © 2011-2022 走看看