如何使用npm加载引导程序? [英] How do I load bootstrap using npm?

查看:72
本文介绍了如何使用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆