“Backbone.Model.extend()不是函数”,我做错了什么?

时间:2022-03-18 06:16:33

I am having a crack at Backbone and decided to open a jsFiddle to play around.

我的脊梁骨裂了,于是决定打开小提琴来玩玩。

Unfortunately, I keep getting this error being thrown:

不幸的是,我一直被抛出这个错误:

Backbone.Model.extend is not a function

Backbone.Model。扩展不是函数

My code:

我的代码:

var Model = Backbone.Model.extend();

I got this piece of code from a Backbone tutorial.

我从主干教程中获得了这段代码。

The fiddle.

小提琴。

What have I done wrong?

我做错了什么?

1 个解决方案

#1


19  

You need to include underscore.js before backbone.js as in this updated version of your fiddle:

您需要包含下划线。js骨干。在你的小提琴的更新版本中:

http://jsfiddle.net/ambiguous/AFmQ2/1/

http://jsfiddle.net/ambiguous/AFmQ2/1/

From the fine manual:

从精美的手册:

Backbone's only hard dependency is Underscore.js.

脊椎骨唯一的硬依赖是Underscore.js。

#1


19  

You need to include underscore.js before backbone.js as in this updated version of your fiddle:

您需要包含下划线。js骨干。在你的小提琴的更新版本中:

http://jsfiddle.net/ambiguous/AFmQ2/1/

http://jsfiddle.net/ambiguous/AFmQ2/1/

From the fine manual:

从精美的手册:

Backbone's only hard dependency is Underscore.js.

脊椎骨唯一的硬依赖是Underscore.js。