【发布时间】:2022-03-23 04:09:13
【问题描述】:
所以在我的 npm 包中,我目前有这个脚本:
"start": "concurrently --kill-others \"npm run dev\" \"electron .\""
问题是,由于当电子运行它的命令时服务器还没有启动,它显示为空白。这可以通过在服务器启动后重新加载应用程序来解决。
所以我想知道是否有一种方法可以通过检测端口或其他方法来等待服务器启动,这样我就不必自己重新加载了。
这是我设置 url 的方式(尝试在其中实现 Vue)。
let format = live ?
url.format({
pathname: path.join(__dirname, 'dist/index.html'),
protocol: 'file:',
slashes: true
})
:
'http://localhost:8080'
// Specify entry point to default entry point of vue.js
win.loadURL(format);
【问题讨论】: