Git Product home page Git Product logo

vue-jsbridge's Introduction

Vue-JsBridge

JsBridge for Vue

android 4.0+ , ios8.0+ 测试通过

引入

main.js:

import JsBridge from './你的路径/jsBridge'
Vue.use(JsBridge)

使用

component.vue:

...
mounted() {
    this.JsBridge.registerHandler(
        'testJs',//注册的方法名,供原生调用
        (data, responseCallback) => {
        data = JSON.stringify(data)//收到原生发来的数据
        ...
        responseCallback("js say: got it!")//处理完成后返回给原生
    })
},
methods:{
    showToast(){
        this.JsBridge.callHandler(
            'toast',//原生声明的函数名称
            { data: `处理成功` },//发送给原生的数据
            (res) => {
                res = JSON.parse(res)//原生处理完成后返回的数据
                ...
            }
        )
    }
}
...

其他

  • 更多 Obj-CJavaScript 交互请参阅 WebViewJavascriptBridge
  • 真机调试可以使用 android 系统设备连接电脑打开 chrome 的 chrome://inspect/#devices 进行调试

vue-jsbridge's People

Contributors

shaww855 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

vue-jsbridge's Issues

hi!可以给出一个demo吗

我使用了你的JS,在android端添加了 “ compile 'com.github.lzyzsd:jsbridge:1.0.4'” ,但是调用没有反应!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.