【发布时间】:2020-03-09 07:10:31
【问题描述】:
我正在尝试在我的项目中使用office-ui-fabric-react。但是我在控制选择输入时卡住了。我想在 OnChange 事件中获取所选项目的值。但是event.target 上没有value。这似乎是div,所以它只有textContent。我必须使用ref 吗?但是当我使用ref 时我并不高兴,因为我相信这不是反应方式。
图书馆:https://developer.microsoft.com/en-us/fabric#/controls/web/dropdown
<Dropdown
label={'Dropdown'}
onChange={e => {
// Not working.
console.log(e.target.value)
}}
options={[
{ text: 'A', key: 'keyA'},
{ text: 'B', key: 'keyB'}
]}
/>
有没有不使用ref的解决方案?
如果我必须使用 ref 我应该怎么做?
【问题讨论】:
标签: reactjs office-ui-fabric office-ui-fabric-react