2023-07-21 19:13:51 +08:00
|
|
|
/**
|
|
|
|
* {}
|
|
|
|
* @author yutent<yutent.io@gmail.com>
|
|
|
|
* @date 2023/07/20 14:19:13
|
|
|
|
*/
|
|
|
|
|
|
|
|
import 'es.shim'
|
|
|
|
import { $, bind } from 'wkit'
|
|
|
|
|
2023-07-25 12:29:31 +08:00
|
|
|
function test1() {
|
2023-07-21 19:13:51 +08:00
|
|
|
try {
|
2023-07-25 12:29:31 +08:00
|
|
|
window.webkit.messageHandlers.app.postMessage({
|
|
|
|
data: { foo: 'Test 1' }
|
2023-07-21 19:13:51 +08:00
|
|
|
})
|
2023-07-25 12:29:31 +08:00
|
|
|
$('#output').innerHTML = '这是没有回调的 '
|
2023-07-21 19:13:51 +08:00
|
|
|
} catch (err) {
|
|
|
|
alert(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-25 12:29:31 +08:00
|
|
|
function test2() {
|
|
|
|
native.handler('blabla', { foo: 'bar' }).then(r => {
|
|
|
|
$('#output').innerHTML = JSON.stringify(r)
|
2023-07-21 19:13:51 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
bind($('.btn1'), 'click', test1)
|
|
|
|
bind($('.btn2'), 'click', test2)
|