You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
381 B
15 lines
381 B
import {
|
|
invoke
|
|
} from 'uni-core/service/bridge'
|
|
|
|
const callbacks = []
|
|
// 不使用uni-core/service/platform中的onMethod,避免循环引用
|
|
UniServiceJSBridge.on('api.uniMPNativeEvent', function (res) {
|
|
callbacks.forEach(callbackId => {
|
|
invoke(callbackId, res.event, res.data)
|
|
})
|
|
})
|
|
|
|
export function onNativeEventReceive (callbackId) {
|
|
callbacks.push(callbackId)
|
|
}
|
|
|