我正在将BackBone集成到一个新项目中.虽然我对BackBone有些熟悉,但这是我第一次尝试用它创建一个新项目.
我设置了一个模型和视图,但是我收到的控制台错误在StackOverflow或Google上没有返回任何helfpul结果.我希望有人能在这里发现我出错的地方.
这是我打电话时发生的错误 thing.fetch()
Uncaught TypeError: Cannot read property 'ajax' of undefined
Run Code Online (Sandbox Code Playgroud)
这是我的CoffeeScript代码:
Thing = Backbone.Model.extend
name: 'thing'
url: ->
"/things/#{@id}"
ThingView = Backbone.Model.extend
el: "#thing"
render: ->
console.log 'render', @$el
thing = new Thing(id: 1)
thing.fetch()
thingView = new ThingView()(model: Thing)
thingView.render()
Run Code Online (Sandbox Code Playgroud)