RT 在input里面输入值,可以改变name 但是不能改变数组的 内容
$(function () {
var person = function(name, children) {
this.name = name;
this.children = ko.observableArray(ko.utils.arrayMap(children,function (item) {
return ko.observable(item)
}));
this.addChild = function() {
this.children.push(" ");
}.bind(this);
}
var model =new person('',[''])
ko.applyBindings(model);
$(".btn").click(function () {
var tmpdata = ko.toJSON(model)
console.log(tmpdata)
});
})
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
可以用ko.observableArray()来监听数组的变化