我发现了很多解决方法。我仍在等待最终解决方案。
解决方法1
因此,我必须将此添加
setTimeout为解决方法。如果我不使用此页面,该页面将永远卡住。
setTimeout(function () { mainWindow.show(); mainWindow.loadURL('http://localhost:5006');}, 3000);解决方法2
它检查bokeh端口是否仍然关闭。但是元素可能未加载且已完全加载
var portscanner = require('portscanner')var _checkServerStatus = setInterval(function() { portscanner.checkPortStatus(5006, '127.0.0.1', function(error, status) { if (status == 'open') { // status = 'open' or 'close' clearInterval(_checkServerStatus); console.log('Server running'); mainWindow.loadURL(bokehUrl); } });}, 100);解决方法3
最终,我找到了另一个解决方法来检查所有元素是否都已完全呈现。答案是这个问题:
oldLog = console.log;console.log = function (message) { if(message.localeCompare('Bokeh items were rendered successfully') == 0){ window.top.postMessage('show-bokeh-iframe', '*') console.log = oldLog; } oldLog.apply(console, arguments);};解决方法4
有一个GH问题,即当bokeh完全加载并呈现时,作者要求调用回调。用户foobarbecue建议验证是否使用
MutationObserver
渲染了bokeh页面,但我从未使用过它。



