1.0.4 • Published 2 years ago

mjsbridge v1.0.4

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago
  1. npm install mjsbridge -S
  2. import webviewBridge from 'mjsbridge'
// Trigger the natively written registration monitoring event'testView', and pass the data
webviewBridge.emit('testView', {a: 1, b: 2}, function() {  // params {a: 1, b: 2} Object form can be used directly, JSON string has been converted internally
              // to do something
           })
webviewBridge.on('testView2', function(data, responseCallback) { // data is the transmitted data
           // to do something
            const d = JSON.parse(data) // Note that the received data must be parsed as a JSON object
//  Example code logic
            if (Number(d.dataKey) === 123) {
                responseCallback(JSON.stringify({color: 'black 321'})) // If you need to send data to the native client, pay attention to JSON string transmission
            } else {
                responseCallback(data)
            }
        })
1.0.4

2 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago