我不确定这是否是一个错误,但是当 1.2.1 可以使用时,knockout.js 2.1 不适用于此示例。 http://jsfiddle.net/gurkavcu/kKNtv/
更新外部资源以使用 2.1 并停止工作: http ://cloud.github.com/downloads/SteveSanderson/knockout/knockout-2.1.0.js
dataList = [ {name:'length1',id:1},
{name:'length2',id:2},
{name:'length3',id:3},
{name:'length4',id:4},
{name:'length5',id:5} ]
var editOfferViewModel = {
selectedLength: ko.observable(),
multiSelectedLength: ko.observableArray()
};
ko.applyBindings(editOfferViewModel);
$(document).ready(function() {
editOfferViewModel.selectedLength(2);
editOfferViewModel.multiSelectedLength(['2','3']);
});