問題描述
我有一個(gè)根目錄中有多個(gè) html 文件的電子應(yīng)用程序.
I have an electron app with multiple html files in the root directory.
- index.html
- page1.html
- page.html
Electro 啟動(dòng)后,我找不到從 index.html 重定向到 page1.html 的方法.
I cannot find a way to redirect from index.html to page1.html once Electro has started.
有人知道怎么做嗎?
推薦答案
當(dāng)你的第一個(gè)頁面是 index.html 你調(diào)用那個(gè)頁面,當(dāng)你創(chuàng)建你的窗口時(shí).
When your first page is index.html you call that page, when you create your window.
const win = new BrowserWindow(options);
win.loadUrl(`file://${__dirname}/index.html`);
如果你想加載另一個(gè)頁面也許
If you want to load another page maybe
win.loadUrl(`file://${__dirname}/page.html`);
可以幫助你.
如果頁面應(yīng)在用戶操作(例如單擊鏈接)后加載.您可以將鏈接添加到您的 index.hmtl 頁面.Electron 在這里的工作方式與瀏覽器完全一樣.
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.
<a href="page.html">Go to page</a>
這篇關(guān)于電子應(yīng)用程序.多個(gè)html文件的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!