【发布时间】:2013-05-07 17:19:42
【问题描述】:
我正在尝试遵循 Brian Mann 制作的优秀教程骨干网。不幸的是(对我来说,因为我是菜鸟)他正在使用咖啡脚本。令人困惑的是我对以下代码的假设:
class App.Views.Users extends Backbone.View
我相信相当于:
Users = Backbone.View.extend({});
在纯 JavaScript 中。但是,当我将咖啡脚本代码放在 trycoffeescript 中时,我得到:
var _ref,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
App.Views.Users = (function(_super) {
__extends(Users, _super);
function Users() {
_ref = Users.__super__.constructor.apply(this, arguments);
return _ref;
}
return Users;
})(Backbone.View);
我的问题是我对纯 javascript 应该产生什么的假设是错误的,是我错误地接近了解释咖啡脚本的方式,还是我超出了希望?
【问题讨论】: