我第一次、第二次和第三次尝试了这些教程,但骨干网仍然无法正常工作。控制台输出显示:“Uncaught TypeError: Cannot call method 'extend' of undefined”
文件夹结构为:
index.html
resources
js
b.js
main.js
meinmodul.js
libs
backbone.js
jquery-1.7.1.js
requireJS_2.1.5.js
underscore.js
索引.html:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<title>test</title>
<!--Require JS -->
<script data-main='resources/js/main' src='resources/libs/requireJS_2.1.5.js'></script</head>
<body>
<div id='wrapper'>
<span>Hallo!</span>
<div id='foo'>foo</div>
</div></body></html>
主.js:
requirejs.config({
paths: {
framework: '../libs',
jquery:'../libs/jquery-1.7.1',
underscore:'../libs/underscore',
backbone:'../libs/backbone'
},
shim: {
'underscore': {
'exports': '_'
},
'backbone': {
'deps': ['jquery', 'underscore'],
'exports': 'Backbone'
},
}
});
require(['jquery', 'meinmodul'], function(jq, meinmodul) {
alert('div foo is foo');
$('#foo').html('bar');
});
require(['jquery','backbone','b'], function(jq, Backbone, test) {
console.log("my backbone view");
});
b.js:
define(['jquery','backbone'], function($,Backbone) {
var SearchView = Backbone.View.extend({
events: {
"click": 'savenow'
},
initialize: function(){
console.log("init1");
console.log($('#testid'));
},
savenow: function(){
console.log("test save method");
}
});
//return SearchView;
return {
'SearchView': SearchView
};
});
我错过了什么或我做错了什么?