我希望使用 nw.js 为我的express.js 应用程序制作可执行文件。自从我开始摆弄 Node.js 以来已经过去了大约 10 天,所以请原谅我的愚蠢错误/措辞。
该应用程序在浏览器上运行良好。有一个表单,我在其中输入 URL 并提交,它将带我到“/getChapters”快速路线,完成一些处理,然后使用结果更新视图。但在 nw.js 中,当我单击按钮后,它只是不断加载、加载、加载。我删除了所有处理部分并添加了 res.send("hi") 只是为了看看它是否到达了路线,但没有。开发工具仅显示客户端内容,甚至没有任何错误。所以我不知道我做错了什么。
这是我所拥有的:
package.json:
"main": "server.js",
index.哈巴狗:
form(action='/getChapter' method='POST')
.input-group
input.form-control(type='text' name='url' placeholder='Paste the URL of the manga' aria-describedby='basic-addon2')
.input-group-append
button.btn.btn-sample(type='submit' style='width:80px !important;')
服务器.js:
app.get('/', function (req, res) {
res.render('index.pug', { chap: [], res: 0 })
})
app.post('/getChapter', function (req, res) {
console.log("hi") //can't even see if this shows
res.send("hi") //doesn't show up
});
server.listen(8081, function () {
console.log("Example app listening at port 8081");
})
nw.Window.open('http://127.0.0.1:8081/', {}, function (win) { });
Node.js:18.16.0
NW.js SDK:0.50.0
Express.js:4.18.2
请帮帮我。预先感谢。
这篇文章已通过在 Windows 10 而不是 Windows 7 上运行来解决。
Windows 7 支持即将消失。有关哪些 NW.js 版本适用于哪些操作系统的更多信息,请查看这篇文章: