twitter-bootstrap 使用 Require.js 从 CDN 加载 Bootstrap
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13464846/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 15:45:07 来源:igfitidea点击:
Loading Bootstrap from CDN with Require.js
提问by Mikko Ohtamaa
Bootstrap is distributed in CDN in
Bootstrap 分布在 CDN 中
Is it possible to load Bootstrap with Require.JS 2.x (shimmed or native AMD)?
How it is possible to load Bootstrap, or any minified JS, directly from CDN URL with Require.js
是否可以使用 Require.JS 2.x(垫片或本机 AMD)加载 Bootstrap?
如何使用 Require.js 直接从 CDN URL 加载 Bootstrap 或任何缩小的 JS
回答by neiker
requirejs.config({
appDir: ".",
baseUrl: "js",
paths: {
/* Load jquery from google cdn. On fail, load local file. */
'jquery': ['//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min', 'libs/jquery-min'],
/* Load bootstrap from cdn. On fail, load local file. */
'bootstrap': ['//netdna.bootstrapcdn.com/bootstrap/3.0.2/js/bootstrap.min.', 'libs/bootstrap-min']
},
shim: {
/* Set bootstrap dependencies (just jQuery) */
'bootstrap' : ['jquery']
}
});
require(['jquery', 'bootstrap'], function($) {
console.log("Loaded :)");
return {};
});

