当viewmodel绑定到html时,我希望第一个div内部"回复"得到一定的外观(css类)当它的isMissing值为真时。
绑定将如何?
function ReplayViewModel(value,isMissing) {
this.value= value;
this.isMissing = isMissing;
}
<div id="replies">
<div></div>
<div></div>
<div></div>
</div>
.specialLook{
background:black;
}
答案 0 :(得分:3)
您正在寻找css
binding:
<div id="replies">
<div data-bind="css: {specialLook: isMissing}"></div>
<div></div>
<div></div>
</div>