我在cshtml中使用了这样一个简单的选择列表
model.availableCountries = ko.observableArray(['France', 'Germany', 'Spain']);
并将以下数据分配给脚本中的选项。
<select data-bind="options: model.contacts,
value: model.selectContactName,
optionsText: 'Name',
optionsCaption: 'Select name'">
</select>
但它并没有绑定任何价值。调试时模型具有此值。我也试过
Dim srcRng As Range
dim trgRng As Range
Dim iii As Long
Dim jjj As Long
Dim iRowStart As Long
Set srcRng = Sheets("your_source_sheet").Range("source_range")
Set trgRng = Sheets("your_target_sheet").Range("target_range")
iRowStart = 4
For iii = iRowStart To UBound(srcRng(), 1)
For jjj = 1 To UBound(srcRng(), 2) ' <~~ necessary only if you were dealing with more than one column
With trgRng
If srcRng(iii, jjj).Value <> "" Then .Cells(.Rows.Count + 1, jjj).Value = srcRng(iii, jjj).Value
End With
Next jjj
Next iii
Set srcRng = Nothing
Set trgRng = Nothing
这甚至没有显示标题。我有什么遗失的吗?
答案 0 :(得分:0)
基于您的问题的基本示例。
const viewModel = {
availableCountries: ko.observableArray(['France', 'Germany', 'Spain']),
countryPlaceholder: 'Where do you live?',
selectedCountry: ko.observable(),
};
ko.applyBindings(viewModel);
&#13;
<select data-bind="options: availableCountries,
value: selectedCountry,
optionsCaption: countryPlaceholder">
</select>
<p data-bind="visible: selectedCountry">
You selected: <span data-bind="text: selectedCountry"></span>
</p>
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.2/knockout-min.js"></script>
&#13;