下面的代码片段——导致一个空的列表框。谁能告诉我做错了什么?
<script src="/Scripts/knockout-2.1.0.debug.js"></script>
<script type="text/javascript">
var listEditorVM = function () {
this.allItems = ko.observableArray(["Apple", "Banana", "Orange"]);
alert(this.allItems().length);
};
ko.applyBindings(new listEditorVM());
</script>
<div>List items:</div>
<select multiple="multiple" data-bind="options: allItems"></select>
作品是 jsFiddle——不在浏览器中