在chrome中绑定数据时出错,即使它在FireFox中运行正常。
<ul data-bind="foreach: contents, visible: contents().length > 0">
<li>
<a data-bind="text: ContentName"></a>
</li>
</ul>
<script type="text/javascript">
function content(data) {
this.ContentName = ko.observable(data.contentName);
}
function contentListViewModel() {
var self = this;
self.contents = ko.observableArray([]); // array of content, populated by ajax
}
</script>
答案 0 :(得分:1)
将viewmodel属性名称更改为小写,并将绑定中的名称更改后,一切都很好了!
<ul data-bind="foreach: contents, visible: contents().length > 0">
<li>
<a data-bind="text: contentName"></a>
</li>
</ul>
<script type="text/javascript">
function content(data) {
this.contentName = ko.observable(data.contentName);
}
function contentListViewModel() {
var self = this;
self.contents = ko.observableArray([]); // array of content, populated by ajax
}
</script>