本文介紹了電子應用程序.多個html文件的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我有一個根目錄中有多個 html 文件的電子應用程序.
I have an electron app with multiple html files in the root directory.
- index.html
- page1.html
- page.html
Electro 啟動后,我找不到從 index.html 重定向到 page1.html 的方法.
I cannot find a way to redirect from index.html to page1.html once Electro has started.
有人知道怎么做嗎?
推薦答案
當你的第一個頁面是 index.html 你調用那個頁面,當你創建你的窗口時.
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`);
如果你想加載另一個頁面也許
If you want to load another page maybe
win.loadUrl(`file://${__dirname}/page.html`);
可以幫助你.
如果頁面應在用戶操作(例如單擊鏈接)后加載.您可以將鏈接添加到您的 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>
這篇關于電子應用程序.多個html文件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!