我试图在我的项目中使用
库:https://developer.microsoft.com/en-us/fabric#/controls/web/dropdown
office-ui-fabric-react
,但遇到了控制选择输入时的困难。我想在OnChange事件中获取所选项目的值。但是event.target
上没有value
。这似乎是div
,因此只有textContent
。我需要使用ref
吗?但是我不喜欢使用ref
,因为我认为这不是react-way。库: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,我应该如何做?