每次窗口开始加载新的html或向服务器发出请求时,窗口将变为白色,直到页面加载完成或服务器响应请求。这看起来不太好,可能会很刺耳。 我该如何解决这个问题?防止页面加载之间发生白色闪烁电子
的代码,如果你想看到它
app.js
const {app, BrowserWindow} = require('electron');
const path = require('path');
const url = require('url');
let win;
function createWindow() {
// Create the browser window.
win = new BrowserWindow({width: 800, height: 600});
win.loadURL(url.format({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file:',
slashes: true
}));
win.on('closed',() => {
win = null;
})
}
app.on('ready', createWindow);
app.on('window-all-closed',() => {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate',() => {
if (win === null) {
createWindow()
}
});
inedx.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body style="background-color: #222222">
<a href="index.html" style="color: white">Click on me to see a flash</a>
</body>
</html>
不幸的是这并没有固定的问题,当它开始和其他的变化都没有明显的effect.I不明白为什么电子做到这一点,因为没有其他Web浏览器这样的行为与背景颜色只影响应用程序。 – Ashlin
我可能只需使用单个页面应用程序 – Ashlin
我面临同样的问题 – Jay