【发布时间】:2017-12-09 11:19:53
【问题描述】:
我是电子新手。我有两个 html 页面,我想在单击按钮时打开第二个页面。我有如下代码,但我只是得到一个空白窗口;不是第二页。
这是 index.js
const electron = require('electron')
const {app, BrowserWindow} = electron
app.on('ready',()=>{
let win = new BrowserWindow({width:960, hehight:540})
win.loadURL(`file://${__dirname}/login.html`)
})
exports.openWindow = (fileName) => {
let win = new BrowserWindow({width:960, height:540})
win.loadURL(`file://${__dirname}/` + fileName + `.html`)
}
这是 login.js
const remote = require('electron').remote
const index = remote.require('./index.js')
var login = document.getElementById('login')
login.addEventListner('click', () => {
var window = remote.getCurrentWindow()
index.openWindow('pageTwo')
window.close()
}, false)
login 是 html 按钮的 id。
我想要第二页。我该怎么做?
【问题讨论】:
-
你想让第二个 html 文件在不同的浏览器窗口中加载吗?
-
@VictoryOsikwemhe 可以更新当前窗口。我只想打开第二页并关闭第一页。
标签: javascript html electron