I가 다음 코드 ... 나는 모든이의 높이에서 시작하는 것이, 3 개체 다양한 개체의 행을 만들기 위해 노력하고Knockout.js if 문
<div data-bind="foreach:profiles">
<!-- ko if: $index() % 3 === 3 -->
<div class="form-group">
<!-- /ko -->
<div class="col-xs-3 col-md-1 no-padding-left">
<img class="img-circle text-center" src="\Content\images\fake_profile_pics\md.png" alt=".." style="opacity: 1.9" />
<h5 class="text-center"><span data-bind="text:Points"></span><span> points</span></h5>
</div>
<div class="col-xs-9 col-md-3">
<a href="#" class="profile_popover people-h2" data-bind="text:DisplayName"></a>
<span class="display-block" data-bind="text:Division"></span>
<span class="display-block"><span data-bind="text:NominationsWritten"></span><span> Nominations Written</span></span>
</div>
<!-- ko if: $index() % 3 === 1 -->
</div>
<!-- /ko -->
</div>
그 위 행의 가장 낮은 요소. 이 코드의 문제점은 knockout이 첫 번째 div에 끝 태그를 찾을 수없고 오류없이 중단된다는 것입니다. 첫 번째 'ko if'문 내에 끝 태그를 넣으면 모든 것이 잘 작동합니다.
녹아웃 주석 달기 방법을 사용하여이 작업을 수행 할 수 있습니까, 아니면 녹아웃으로이 문제를 해결할 수있는 더 많은 방법이 있습니까?
if 문을 다시 작성하지 않으시겠습니까? 코드에서 요소를 정렬 한 다음 foreach를 실행하십시오. – Pseudonym
BTW :'if : $ index() % 3 === 3'이 문은 * never * true입니다. 아마도 $ index() % 3 === 0'을 의미 할 것입니다. –