atom-shell只有从URL加载HTML的方法。
window.loadUrl('file://...')
但我想使用Jade
var html = jade.renderFile('file://...');
有没有办法在atom-shell的窗口中使用编译后的
html
?比如loadHtml(html)
这样的东西?我猜我可以运行一个express服务器来提供编译后的html,但那会非常低效。
如果是Mac电脑:
/usr/bin/open -a "/Applications/Google Chrome.app" --args 'data:text/html,<html><body><h1>title</h1><p>text</p></body></html>'
URI 的详细信息
另一种选择是使用executeJavaScript函数,例如:
mainWindow.loadUrl('about:blank');
var s = '<DOCTYPE html><html><head><title>Written!</title></head><body><h1>Hello!</h1></body></html>';
mainWindow.webContents.executeJavaScript('document.write("' + s + '");');