# Evaluate Js Async
运行异步Javascript代码并调用回调。
import webview
def callback(result):
print(result)
def evaluate_js_async(window):
window.evaluate_js(
"""
new Promise((resolve, reject) => {
setTimeout(() => {
resolve('Whaddup!');
}, 300);
});
""", callback)
if __name__ == '__main__':
window = webview.create_window('Run async Javascript', html='<html><body></body></html>')
webview.start(evaluate_js_async, window)
← Evaluate Js Events →