[英]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.