我对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