我想为我的网站使用 bootstrap(使用 node.js)。但我有以下错误:
/var/www/node_modules/bootstrap/js/transition.js:59
}(jQuery);
^
ReferenceError:jQuery 未定义
在对象。 (/var/www/node_modules/bootstrap/js/transition.js:59:3)
在 Module._compile (module.js:456:26)
在 Object.Module._extensions..js (module.js:474:10)
在 Module.load (module.js:356:32)
在 Function.Module._load (module.js:312:12)
在 Module.require (module.js:364:17)
在需要时(module.js:380:17)
在对象。 (/var/www/node_modules/bootstrap/dist/js/npm.js:2:1)
在 Module._compile (module.js:456:26)
在 Object.Module._extensions..js (module.js:474:10)
我尝试做一个
var bootstrap = require('bootstrap');
在我的主节点中。
我用 npm 安装了 bootstrap (npm install bootstrap
从我的文件夹中)。我还尝试以相同的方式安装 jquery 并添加var jQuery= require('jquery');
但它不起作用。您知道可能出了什么问题吗?我正在启动node.js,我可能会错过一些东西
然后我用<link href="../node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
在我的 HTML 网页中引用 bootstrap
`
要将 jquery 插件与 npm/node 一起使用,您需要在需要插件之前设置全局 jQuery 变量 [在本例中为 bootstrap]:
global.jQuery = require('jquery');
require('bootstrap');
更多细节在此npm 博客 http://blog.npmjs.org/post/112064849860/using-jquery-plugins-with-npmpost
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)