Backbone.js的:`extend`未定义? [英] Backbone.js: `extend` undefined?

查看:250
本文介绍了Backbone.js的:`extend`未定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

刚开始接触Backbone.js的。简单地包括骨干网(无论是开发/生产版本)会导致错误:

Just getting started with Backbone.js. Simply including Backbone (either dev/production versions) causes the error:

未捕获类型错误:无法调用128线未定义扩展:

//附上所有可继承的方法与模型的原型。
  _.extend(Backbone.Model.prototype,Backbone.Events,{

推荐答案

的问题是,我没有装 underscore.js 。我完全错过了文档的依赖。咄。

The issue was that I wasn't loading underscore.js. I totally missed that dependency in the docs. Duh.

进一步澄清@tjorriemorrie:
我不得不强调,但在错误的顺序,先装下划线加载(猜这就是依赖是指:)

Further clarification from @tjorriemorrie: I had underscore, but loaded in the wrong order, first load underscore (guess that is what 'dependency' means :)

进一步明确以防万一,这并不明显。事情在JavaScript的加载顺序涉及显示在页面上的顺序。首先装载下划线,确保脚本标记,包括它的一个装载骨干之前。像这样的:

Further Clarification just in case this isn't obvious. The order that things are loaded in JavaScript relates to the order the show up on the page. To load underscore first, be sure that the script tag including it comes before the one loading backbone. Like this:

<script src="underscore-1.4.4-min.js"></script>
<script src="backbone-1.0.0-min.js"></script>

这篇关于Backbone.js的:`extend`未定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆