我试图在semantic-ui-react下拉菜单上工作,当我试图更新状态时,我得到了这个错误。我找到了HTMLInput/Select/TextArea元素,但它不适用于dropdown。
handleDrilldownPageChange(event:any) { //any has to be replaced by some HTMLElement and thats my problem
this.setState({
pageCode: {
text: event.target.value as PageCode
}
});
}
//if i give "any" type to an event, it wouldnt update my state because it doesnt grab any value from the target
以下是我在render中的代码
<Dropdown
style={{
minWidth: "210px",
display: "block"
}}
selection
options={optionTypes}
value={this.state.pageCode.text}
onChange={this.handleDrilldownPageChange}
/>
谢谢你们。如果能帮上忙我会很感激。
发布于 2020-01-01 10:35:02
由于dropdown数据呈现为单个单独的div,因此无法使用event.target.value
检索值。相反,您可以尝试使用event.target.innerText
获取内部div文本
https://stackoverflow.com/questions/59551509
复制相似问题