我在淘汰赛js中有如下程序
<input type="text" data-bind="value:firstName" />
<input type="text" data-bind="value:lastName" />
<p data-bind="text:fullName"></p>
<script type="text/javascript" language="javascript">
// Here's my data model
var Person = function (id, first, last) {
this.id = ko.observable(id);
this.firstName = ko.observable(first);
this.lastName = ko.observable(last);
};
Person.prototype.fullName = ko.computed(function () {
return this.firstName() + " " + this.lastName();
}, Person);
ko.applyBindings(new Person(1, "kapil", "Garg"));
</script>
我收到 this.firstName() 不是函数的错误。我怎样才能添加这样的新计算机属性?