每次窗口開始加載新的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