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.
16 lines
381 B
16 lines
381 B
|
3 years ago
|
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)
|
||
|
|
}
|