javascript 电子应用程序。多个html文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33599908/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 16:40:12  来源:igfitidea点击:

Electron app. Multiple html files

javascriptnode.jselectron

提问by Dany

I have an electron app with multiple html files in the root directory.

我有一个电子应用程序,根目录中有多个 html 文件。

  • index.html
  • page1.html
  • page.html
  • 索引.html
  • 页面1.html
  • 页面.html

I cannot find a way to redirect from index.html to page1.html once Electro has started.

一旦 Electro 启动,我就找不到从 index.html 重定向到 page1.html 的方法。

Does anyone know how to do this?

有谁知道如何做到这一点?

回答by apxp

When your first page is index.html you call that page, when you create your window.

当您的第一个页面是 index.html 时,您在创建窗口时调用该页面。

const win = new BrowserWindow(options);
win.loadUrl(`file://${__dirname}/index.html`);

If you want to load another page maybe

如果你想加载另一个页面

win.loadUrl(`file://${__dirname}/page.html`);

could help you.

可以帮助你。

If the page should be loaded after a user action (e.g. click on a link). You can add the link to your index.hmtl page. Electron works here exactly like a browser.

如果页面应该在用户操作(例如单击链接)之后加载。您可以将链接添加到您的 index.hmtl 页面。Electron 在这里就像浏览器一样工作。

<a href="page.html">Go to page</a>