[英]Loading Bootstrap with AMD Modules and typescript
我正在尝试使用RequireJS和typescript AMD模块加载Bootstrap。
目前我在requireJS配置中有以下内容:
require.config({
shim: {
bootstrap: { deps: ["jquery"] }
},
paths: {
jquery: "//code.jquery.com/jquery-2.1.4.min",
bootstrap: "//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min",
d3: "//d3js.org/d3.v3.min"
}
});
然后在我想做的课上:
import jq = require("jquery");
import bootStrap = require("bootstrap");
class test {
public doStuff(): void {
jq("#test").carousel();
}
}
这是由typescript编译成:
define(["require", "exports", "jquery"], function (require, exports, jq) {
var testViewModel = (function () {
function testViewModel() {
}
testViewModel.prototype.doStuff = function () {
jq("#test").carousel();
};
return testViewModel;
})();
})
所以问题似乎是因为bootstrap扩展了jquery并且实际上没有直接使用它不会输出到编译的javascript中。
我可以在我的课程中的某处包含一个引导程序来修复问题,但这有点容易出错。
我错过了什么?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.