【发布时间】:2026-01-31 14:25:05
【问题描述】:
我的页面上有一个选择标签:
open Fable.Helpers.React
open Fable.Helpers.React.Props
select []
[
option [ Value "a" ] [ str "a" ]
option [ Value "b" ] [ str "b" ]
option [ Value "c" ] [ str "c" ]
]
转译为:
<select>
<option value="a">a</option>
<option value="b">b</option>
<option value="c">c</option>
</select>
现在,假设我希望“b”具有selected 属性。我试试:
option [ Value "b"; Selected true ] [ str "b" ]
HTML 中没有任何变化。而如果我例如试试:
option [ Value "b"; Disabled true ] [ str "b" ]
HTML 会相应改变:
<option value="b" disabled="">b</option>
那么如何处理“selected”属性呢?我需要得到:
<option value="b" selected="">b</option>
【问题讨论】: