Knockout JS - Use both static class name as well as data bound class name
问题 Anyone know if I can have an html element with both a static class name as well as a dynamic, data-bound class name using KnockoutJS? Something like this: <span class='staticClassName {{viewModelPropertyValue}}'></span> I realize this isn't ko syntax, I'm just using this syntax to get the point across. 回答1: You can use the css binding to add and remove a class based on the truthiness of a value, but it sounds like your viewModelProperty is the name of a class rather than a boolean. You can