gpt4 book ai didi

javascript - backbone.js model.set 不工作

转载 作者:数据小太阳 更新时间:2023-10-29 05:02:41 27 4
gpt4 key购买 nike

<分区>

我正在尝试使用 backbone.js model.set 属性。第二个警报功能应该在执行 todo1.set 后触发。然而事实并非如此。
这是 jsfiddle 链接: http://jsfiddle.net/SGEkn/

var Todo = Backbone.Model.extend({
defaults: {
title: "Harsh",
completed: false
},
initialize: function() {
console.log('This model has been initialized.')
}
});

var todo2 = new Todo({
title: 'Set through instantiation.',
completed: true
});
console.log('Todo title: ' + todo2.get('title'));
console.log('Todo completed ' + todo2.get('completed'));

alert("ok");

todo2.set("title", 'Title set');

alert("ok");

console.log(todo2.get('title'));
todo.set("completed", false);

console.log('completed: ' + todo2.get('completed'));

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com