我是 automapper KO 的新手。我有这个代码:
var jData = [
{ "Id": 2, "Name": "A" },
{ "Id": 3, "Name": "B" },
{ "Id": 4, "Name": "C" }]
};
var viewModel = ko.mapping.fromJSON(JSON.stringify(jData));
ko.applyBindings(viewModel);
此代码有效:
<div data-bind="foreach : $data">
<input type="text" data-bind='value: Name' />
<br />
</div>
但如果我想通过地图选择:
<select id="prova" data-bind='options: $data, optionsText: "Name", optionsValue: "Id" , value: Id'></select>
我收到了这个错误
启用以解析绑定。消息:ReferenceError:'Id' 未定义;绑定值:options: $data, optionsText: "Name", optionsValue: "Id" , value: Id
怎么了?谢谢 L