如何使用npm加载引导程序? [英] How do I load bootstrap using npm?
问题描述
我有一个使用jquery的npm项目.
I have a npm project that uses jquery.
var $ = require('jquery');
我还有一个索引HTML文件,该文件引用了引导程序.
I also have an index html file that references bootstrap.
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet"/>
<script type="text/javascript" src="my-script.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js"></script>
现在我需要为jquery单独加载以进行引导,因为它取决于它吗?我最近使用的是jqueryify
而不是jquery
,我不需要单独的加载.
Now do I need to a separate load for jquery for bootstrap as it depends on it? I was recently using jqueryify
instead of jquery
and I did not need the separate load.
有人可以建议将bootstrap的加载模式与require一起使用吗?
Can anyone recommend a loading pattern for bootstrap with use with require?
推荐答案
Bootstrap现在是引导程序支持的节点程序包.
Bootstrap is now a supported node package by the bootstrap guys.
https://www.npmjs.org/package/bootstrap
这意味着您现在可以在代码中要求引导.是这样.
What this means is you can now require bootstrap in code. So.
npm install bootstrap --save
npm install jquery --save
foo.js
var $ = require('jquery');
window.$ = $;
require('bootstrap');
这篇关于如何使用npm加载引导程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!