首页 > 解决方案 > 在办公室 ui 结构中,如何在按钮单击时获得默认选定值

问题描述

在我的应用程序中,我使用了 office ui fabric react 下拉控件,当我单击按钮时,我需要检查它是否为空?

public options = [
    { key: 'Employee Name', text: 'Employee Name' },
    { key: 'Employee ID', text: 'Employee ID' },
    { key: 'Department', text: 'Department' }
];

<Dropdown defaultSelectedKey="Employee Name" options={this.options} onChange={this._onChange} />
<input type="button" value="Get Data" id="btnSub" onClick={() => this.readItem()} />


private readItem(): void {
    what I need to do here
}

标签: office-ui-fabric

解决方案


从事件目标中读取值。

(e) => this.readItem(e.value.target)


推荐阅读