所以我有我的可观察数组
answer: ko.observableArray("")
我尝试使用data-bind来访问answer()[0]
<div id="iAnswer" style="display: inline-block; text-align: right; width: 80%; border: 0px;"
data-bind="dxTextBox: { value: answer()[$data.index], text:$data.answer}"></div>
$ data.index在通过时等于0。
答案 0 :(得分:0)
此代码是否解决了您的任务?
<!-- ko if: answer().length === 0 -->
<div> There are no answers. </div>
<-- /ko -->
<!-- ko ifnot: answer().length === 0 -->
<div id="iAnswer" style="display: inline-block; text-align: right; width: 80%; border: 0px;"
data-bind="dxTextBox: { text:$data.answer }"></div>
<-- /ko -->