电子脚本中的loadhtml而不是loadUrl,链接不起作用

我做同样的事情,在这个问题上 ,给我的模板数据,编译它,使它看起来像一个文件

var file = 'data:text/html,' + encodeURIComponent(compiled); 

所有看起来不错,模板成功呈现,我得到我的数据,但现在我的标签在头上停止工作,标签像链接或脚本与src属性

在这里,我通过ID MAZ-63171获取pouchdb中的文档,并将该文档提供给我的模板:

 db.get('MAZ-63171') .then(function(doc) { var compileFn = pug.compileFile('./pugTemplates/index.pug', { pretty: true }); var compiled = compileFn({doc: doc}); console.log(compiled); // console.log(doc); // 'file://' + __dirname + '/pugTemplates/index.pug' var file = 'data:text/html,' + encodeURIComponent(compiled); mainWindow.loadURL(file); }) .catch(function(err) { console.log(err); }); 

在index.pug我有这个

 doctype html html(lang="en") head title="trucks" link(rel="stylesheet" href="../node_modules/semantic-ui/dist/semantic.min.css") //- script window.$ = window.jQuery = require('jquery'); script(src="../node_modules/jquery/dist/jquery.min.js") script(src="../node_modules/semantic-ui/dist/semantic.min.js") body .ui.container .ui.grid .four.wide.column .eight.wide.column |#{doc._id} table.ui.celled.table thead tr th Header th Header th Header tbody tr td .ui.ribbon.label First td Cell td Cell tr td Cell td Cell td Cell tr td Cell td Cell td Cell 

编译到这

 <!DOCTYPE html> <html lang="en"> <head> <title>trucks</title> <link rel="stylesheet" href="../node_modules/semantic-ui/dist/semantic.min.css"> <script src="../node_modules/jquery/dist/jquery.min.js"></script> <script src="../node_modules/semantic-ui/dist/semantic.min.js"></script> </head> <body> <div class="ui container"> <div class="ui grid"> <div class="four wide column"></div> <div class="eight wide column">MAZ-63171</div> <table class="ui celled table"> <thead> <tr> <th>Header</th> <th>Header</th> <th>Header</th> </tr> </thead> <tbody> <tr> <td> <div class="ui ribbon label">First</div> </td> <td>Cell</td> <td>Cell</td> </tr> <tr> <td>Cell</td> <td>Cell</td> <td>Cell</td> </tr> <tr> <td>Cell</td> <td>Cell</td> <td>Cell</td> </tr> </tbody> </table> </div> </div> </body> </html> 

我收到关于css或js文件添加的零错误,但是semantic-ui不能正常工作,正如您在截图中看到的那样

为什么会发生这种情况,如何解决? 我想这是因为那些转换成string,也许我应该使用其他方法来编译我的模板。

从npm的电子帕格模块似乎不从当地人得到的数据,它等待它的承诺,在那个时候标准loadUrl加载哈巴狗模板直接进入窗口,而不呈现它。 也许我做错了。