📜  如何将 json 输出结果绑定到任何新模型 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:48.746000             🧑  作者: Mango

代码示例1
var viewModel = {
    firstName : ko.observable("Bert"),
    lastName : ko.observable("Smith"),
    pets : ko.observableArray(["Cat", "Dog", "Fish"]),
    type : "Customer"
};
viewModel.hasALotOfPets = ko.computed(function() {
    return this.pets().length > 2
}, viewModel)