我試圖配置RequireJS從我的網站上的另一個文件夾加載jQuery,而不是其他所有文件夾的/Scripts
文件夾。我正在用Fiddler觀看頁面加載,並且我總是看到jQuery請求會出現在/Scripts/jquery.js
而不是正確的URL。jQuery的RequireJS配置
在我的標記,我有這樣的:
<script src="@Url.Content("~/Scripts/require.js")" type="text/javascript" data-main="@Url.Content("~/Scripts/main")"></script>
在/Scripts/main.js
我有這樣的:
require.config({
waitSeconds: 10,
paths: {
"jquery": "/N2/Resources/Js/jquery-1.7",
"modernizr": "modernizr-2.0.6-development-only"
}
});
require(["jquery", "jquery.utility", "jquery.link-decorators", "jquery.google-analytics", "accessibility", "modernizr"], function ($) {
... omitted
});
在提琴手,我看到正確的Modernizr要求出去,但jQuery的要求去爲/Scripts/jquery.js
。
作爲一項測試,我將我的modernizr行更改爲"modernizr" : "/N2/Resources/Js/modernizr-2.0.6-development-only"
,並且我看到請求發送給該資源(當然它返回404)。所以我知道RequireJS看到我的配置,並正在處理它。
注意:我知道在RequireJS中處理jQuery的各種方法。我的所有插件都定義了模塊,所以亂序加載不會成爲問題。我正在使用jQuery 1.7,這是AMD的意識。
接受你的答案,哈哈。 – theblang 2012-12-12 00:52:41