【发布时间】:2019-10-31 02:55:56
【问题描述】:
我关注Electron quick start guide,它可以正常工作,但输出与文档中描述的不同,document.write 的版本不会显示在输出中。
这是我的输出:
Hello World!
We are using node , Chrome , and Electron .
我的预期输出将包括相应的版本号。
我检查了应用程序的 GitHub 页面,还是一样,尝试了各种 StackOverflow 答案,但没有一个对我有用。
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
We are using node <script>document.write(process.versions.node) </script>,
Chrome <script>document.write(process.versions.chrome)</script>,
and Electron <script>document.write(process.versions.electron) </script>.
</body>
</html>
package.json
{
"name": "electronapp",
"version": "1.0.0",
"description": "",
"main": "main.js",
"scripts": {
"start": "electron ."
},
"author": "harsh",
"license": "ISC",
"devDependencies": {
"electron": "^5.0.2"
}
}
main.js
const {app, BrowserWindow} = require('electron')
const path = require('path')
let mainWindow
function createWindow () {
mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
preload: path.join(__dirname, 'preload.js')
}
})
mainWindow.loadFile('index.html')
mainWindow.on('closed', function () {
mainWindow = null
})
}
app.on('ready', createWindow)
app.on('window-all-closed', function () {
if (process.platform !== 'darwin')
app.quit()
})
app.on('activate', function () {
if (mainWindow === null)
createWindow()
})
我已经全局安装了 Node,Chrome 是用 Electron 打包的,对吧?
【问题讨论】:
-
你安装依赖了吗?
-
检查我的编辑,我不确定我是否回答了你的问题。
-
如果可以的话,请添加您的
main.js和一些输出截图。 -
我已按照您的要求添加了 main.js 文件和屏幕截图链接。