0

这是我的模板:

<!-- TEMPLATE -->
<div id="templateDiv" data-win-control="WinJS.Binding.Template">
    <div class="tile" data-win-bind="textContent: QuestionText"></div>
</div>

我的输出是这样的:

<div id="itemsControl" data-win-control="Samples.ItemsControl">
    <div class="win-template">
        <div class="tile" data-win-bind="textContent: QuestionText">Sample Data 1</div>
    </div>
    <div class="win-template">
        <div class="tile" data-win-bind="textContent: QuestionText">Sample Data 2</div>
    </div>
    <div class="win-template">
        <div class="tile" data-win-bind="textContent: QuestionText">Sample Data 3</div>
    </div>
    <div class="win-template">
        <div class="tile" data-win-bind="textContent: QuestionText">Sample Data 4</div>
    </div>
</div>

我想覆盖 class=" win-template " 或添加到输出中的 class 属性。我试图将 class="sample-class" 放在 templateDiv 中,但没有运气。它似乎覆盖了我尝试的一切。

4

1 回答 1

0

The win-template class is just a class that the WinJS.Binding.Template control adds to each rendering of a template to mark them as such. The WinJS stylesheets don't actually define any styles for win-template, so you're free to assign any styles you want, i.e.

#itemsControl .win-template {
    /* Your styles here */
}

Alternately, start your template with another that is the container for the rest of the template, and the Template control won't do anything to it.

于 2013-08-02T16:20:39.030 回答