我一直在开发 Meteor 应用程序,并希望通过 Backbone 的路由功能添加多页功能。但是,当我这样做时:
meteor add backbone
meteor add underscore
然后尝试在应用程序中创建一个简单的“hello World”,它会因消息而崩溃:
ReferenceError: Backbone is not defined
at app/backbone.js:33:2
at run (/Users/timj/Documents/backbone/.meteor/local/build/server/server.js:142:63)
at Array.forEach (native)
at Function._.each._.forEach (/usr/local/meteor/lib/node_modules/underscore/underscore.js:79:11)
at run (/Users/timothyjaeger/Documents/backbone/.meteor/local/build/server/server.js:142:7)
Exited with code: 1
不知道我做错了什么,因为我已经在我的流星应用程序中添加了主干!js看起来像这样:
骨干测试app.js
if (Meteor.isClient) {
var AppView = Backbone.View.extend({
// el - stands for element. Every view has a element associate in with HTML content will be rendered.
el: '#container',
// It's the first function called when this view it's instantiated.
initialize: function(){
this.render();
},
// $el - it's a cached jQuery object (el), in which you can use jQuery functions to push content. Like the Hello World in this case.
render: function(){
this.$el.html("Hello World");
}
});
var appView = new AppView();
}
if (Meteor.isServer) {
Meteor.startup(function () {
Backbone.history.start({pushState: true});
// code to run on server at startup
});
}