是否建议在原型对象上创建计算属性?
这是我在下面尝试的但是firstName绑定将函数作为字符串返回而不是执行它(http://jsfiddle.net/W37Yh).
var Homeviewmodel = function(config,$,undefined) { if (!this instanceof Homeviewmodel) { return new Homeviewmodel(config,undefined); } this.firstName = ko.observable(config.firstName); this.lastName = ko.observable(config.lastName); }; Homeviewmodel.prototype.fullName = function() { return ko.computed(function() { return this.firstName() + " " + this.lastName(); },this); }; var model = new Homeviewmodel({ firstName: "John",lastName: "Smith" },jQuery); ko.applyBindings(model);