Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/444.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ElectronJS BrowserWindow FOUC_Javascript_Css_Electron - Fatal编程技术网

Javascript ElectronJS BrowserWindow FOUC

Javascript ElectronJS BrowserWindow FOUC,javascript,css,electron,Javascript,Css,Electron,当我创建一个新的BrowserWindow并使用loadURL在渲染器中使用html文件时,我可以在加载css之前看到半秒钟未设置样式的内容 window.loadURL('file://' + resolve(__dirname, '..', 'static', 'hello-world', 'index.html') 在index.js中 import './index.css' 您需要将窗口创建为隐藏,一旦加载内容(完成加载事件),您将显示它。这样可以防止闪烁 主流程代码 const

当我创建一个新的BrowserWindow并使用loadURL在渲染器中使用html文件时,我可以在加载css之前看到半秒钟未设置样式的内容

window.loadURL('file://' + resolve(__dirname, '..', 'static', 'hello-world', 'index.html')
在index.js中

import './index.css'

您需要将窗口创建为隐藏,一旦加载内容(完成加载事件),您将显示它。这样可以防止闪烁

主流程代码

const win=新浏览器窗口({
宽度:800,
身高:600,
show:false,//加载窗口而不显示它
网络首选项:{
preload:path.join(uu dirname,'preload.js')
}
})
win.loadFile('index.html')
win.webContents.on('did-finish-load',函数(){
win.show()//现在显示窗口,因为一切都准备好了
})

如果用
window.loadURL(
文件://${uuuu dirname}/index.html
)替换
loadURL
调用,你会看到什么?
并且你的css导入行在html文件的顶部吗?我必须使用路径解析,因为构建有那个路径,但没有区别,是的,css在顶部。我想知道这是否是创建新浏览器窗口的“官方”方式。@jorgotega是否要显示初始屏幕?