【发布时间】:2021-09-22 17:51:11
【问题描述】:
我正在使用 fluentui/react-northstar 库。我正在使用下拉组件并使用 onChange 处理程序。我无法从 onChangeHandler 方法的下拉列表中获取当前选定的值。
我的代码sn-p
import React from "react";
import { Flex, Header, Dropdown } from '@fluentui/react-northstar';
class DropdownComponent extends React.Component {
constructor(props) {
super(props);
this.state = {
inputItems: [
'Robert Tolbert',
'Wanda Howard',
'Tim Deboer',
'Amanda Brady',
'Ashley McCarthy',
'Cameron Evans',
'Carlos Slattery',
'Carole Poland',
'Robin Counts',
]
}
this.onChangeHandler = this.onChangeHandler.bind(this);
}
onChangeHandler(e){
//e => null
//Need to get the selected value from dropdown
}
render() {
return (
<section>
<Flex column gap="gap.small">
<Header as="h4" content="Object" />
<Dropdown
items={this.state.inputItems}
placeholder="Select your object"
checkable
onChange={(e) => this.onChangeHandler(e)}
/>
</Flex>
</section>
);
}
}
export default DropdownComponent;
谁能提供有关如何从 onChange 处理程序中获取所选值的详细信息。
【问题讨论】: