我對Backbone相當陌生,今天剛開始嘗試學習AMD。我從RequireJS的網站安裝了RequireJS-jQuery庫。所以這是我的腳本標籤,其中有Laravel路徑調用:jQuery和Underscore未在RequireJS中加載
<script data-main="{{ path('js/main') }}"
src="{{ path('js/libs/requirejs/require-jquery.js') }}"></script>
我想正確確保一切加載,所以我想我的console.log
依賴。骨幹返回一個對象就好了。 Underscore和jQuery不。這裏是我的main.js
文件:
require.config({
baseUrl: '../js/',
paths: {
jquery: 'libs/jquery/jquery-1.8.3.min',
underscore: 'libs/underscore/underscore-min',
backbone: 'libs/backbone/backbone-min'
}
});
if (typeof define === "function" && define.amd && define.amd.jQuery) {
define('jquery', [], function() { return jQuery; });
}
//the "main" function to bootstrap your code
require(['jquery', 'underscore', 'backbone', 'app'],
function() {
var App = require('app');
//App.initialize();
console.log($);
console.log(_);
console.log(Backbone);
});
我有幾個問題,我需要爲jQuery的路徑,因爲它是RequireJS,jQuery庫的一部分?二,這是什麼關於勻場?我是否需要爲此付諸實施?我正在使用RequireJS-jQuery的v 2.1.4。
我試過以下this post,但無法正常工作。我使用的是Backbone和Underscore的AMD版本。爲什麼不會下劃線和jQuery console.log
?
當我說,他們不會CONSOLE.LOG我的意思是,它返回'函數()' – sehummel