如何計算函數this.followButtonText不更新,始終顯示(Follow),何時可觀察this.isFollowing發生更改? 。 $(文件)。就緒(函數(){Knockouts ko.computed變量在更改obserable時不會更新
function AppViewModel() {
this.toggleIsFollowing = function() {
this.isFollowing = !this.isFollowing;
follow();
};
this.isFollowing = ko.observable(false);
this.followButtonText = ko.computed(function() {
return this.isFollowing ? "Unfollow" : "Follow";
});
}
ko.applyBindings(new AppViewModel());
}
});
</script>
啊,謝謝你忘了那些! – Nikos