【发布时间】:2021-12-15 10:31:57
【问题描述】:
我正在研究淘汰赛js并发生错误 有什么问题??
<span data-bind="text: fullname"></span>
<script type="text/javascript">
function AppViewModel() {
this.firstName = ko.observable('Bob');
this.lastName = ko.observable('Smith');
this.fullname = ko.computed(function() {
return this.firstname() + " " + this.lastname();
},this);
}
// <!-- ko.applyBindings(viewModel); -->
var vm = new AppViewModel();
ko.applyBindings(vm);
</script>
当我调用这个时,
Uncaught TypeError: this.firstname is not a function
发生... 怎么了?
【问题讨论】:
-
查看大小写...
this.firstName = ...和return this.firstname() + ...。您的this.lastName/this.lastname变量也存在此问题