我用这段代码得到一个奇怪的样式文本:
self.styleClass = ko.computed(function () {
return self.isFollowing() ? "button" : "secondary button";
});
<button data-bind="text: followButtonText,click: toggleIsFollowing, css: styleClass"></button>
它呈现:
<button data-bind="text: followButtonText,click: toggleIsFollowing, css: styleClass" class=" 0 1 2 3 4 5 6 7 8 9 10 11 12">Unfollow</button>
model.styleClass() 在控制台中呈现良好