我正在尝试将模型与服务器同步。不幸的是,尽管在模型上设置url
和rootUrl
,我仍然得到url property is not specified。
不用说我可以model.fetch()
用这个模型做(GET)就好了,但是当我尝试 POST 时,我突然失去了URL。
>>> model = window.mod
ClientSchema { cid="c2", attributes={...}, _changing=false, more...}
>>> model.url
"http://localhost:8080/mp/add"
>>> model.urlRoot
"http://localhost:8080/mp/add"
>>> model.set({test:2})
ClientSchema { cid="c2", attributes={...}, _changing=false, more...}
>>> model.sync()
Error: A "url" property or function must be specified
urlError()vendor.js
Backbone.sync()vendor.js
.sync()vendor.js
throw new Error('A "url" property or function must be specified');
模型
# coffeescript
# Chaplin.Model just extends Backbone.Model
module.exports = class ClientSchema extends Chaplin.Model
url: 'http://localhost:8080/mp/add'
urlRoot:'http://localhost:8080/mp/add'
模型同步
>>> model.sync.toString()
"function () {
return Backbone.sync.apply(this, arguments);
}"