Electron loading html inside pre tag

元气小坏坏 提交于 2021-01-27 23:58:38

问题


I recently created an electron/angular app which runs the following inside main.ts:

win.loadURL(url.format({
  pathname: path.join(__dirname, 'dist/index.html'),
  protocol: 'file:',
  slashes: true
}));

When the electron app loads, the following shows Somehow, the html is loading inside a <pre> tag inside html. I have checked __dirname/dist and the folder contains all the correct files (i.e. index.html, main.js, etc). Has anyone seen something similar with electron before? If so, any clues as to what is happening?


回答1:


While not totally obvious, I fixed my issue - my win object was throwing warnings since I am using service workers and therefore, did not load the html properly.

The solution: use the nodeIntegrationInWorker: true property. Once that was added everything worked like magic.

  // Create the browser window.
  win = new BrowserWindow({
    x: 0,
    y: 0,
    width: size.width,
    height: size.height,
    webPreferences: {
      nodeIntegration: true,
      nodeIntegrationInWorker: true
    }
  });


来源:https://stackoverflow.com/questions/55128495/electron-loading-html-inside-pre-tag

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!