【发布时间】:2018-08-04 17:41:58
【问题描述】:
由于源代码安全功能,我正在将我的桌面应用程序从 electron 切换到 nw.js。
我在我的 nodejs 文件中需要模块 jquery-confirm,我收到此错误:
Uncaught Error: jquery-confirm requires jQuery
我通过以下方式修复此错误:
var $ = require('jquery');
window.jQuery = $;
var jconfirm = require('jquery-confirm');
并像这样在 index.html 中导入 js 文件:
<script>require('./bot.js')</script>
因为如果我需要这样的 js 文件,我会得到相同的 jquery 错误:
<script src="bot.js"></script>
当我修复上述错误并使用 nw.js 启动应用程序时,它会立即崩溃并给出此错误:
TypeError: $(...).button is not a function
第一个问题: 我假设jquery有问题。当我在 index.html 中导入它时,它根本不起作用。但是,在 js 文件中需要它后,我仍然遇到问题。我该如何解决这个问题?
第二个问题: 如果我使用 'require' 而不是导入我的 js 文件,为什么我没有收到 Uncaught Error: jquery-confirm requires jQuery 错误?
【问题讨论】:
标签: javascript node-webkit nw.js nwjs