我不知道为什么,但我无法让它工作。
var friends = new Backbone.Collection([
{name: "Athos", job: "Musketeer"},
{name: "Porthos", job: "Musketeer"},
{name: "Aramis", job: "Musketeer"},
{name: "d'Artagnan", job: "Guard"},
]);
friends.where({job: "Musketeer"}).toJSON()
我得到Uncaught TypeError: Object [object Object] has no method 'toJSON'
。
我做错了什么,如何将过滤后的集合转换为 JSON?