[英]Aurelia - Set default value in dropdown
I have a drop-down which is populated from a JavaScript array. 我有一个从JavaScript数组填充的下拉菜单。
let a = [90, 95, 99];
When I bind this array in the HTML as follows, the initial value is set to 90. 当我按如下所示在HTML中绑定此数组时,初始值设置为90。
<select>
<option repeat.for="i of a">${i}</option>
</select>
But I need to show '95' as the default value. 但是我需要显示“ 95”作为默认值。 So how can I achieve this? 那么我该如何实现呢?
You can bind the value of the select to a certain value, which it will take as default. 您可以将select的值绑定到某个值,该值将作为默认值。
let a = [90, 95, 99];
let selectedValue = 95;
Html: HTML:
<select value.bind="selectedValue">
<option repeat.for="i of a">${i}</option>
</select>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.