gpt4 book ai didi

javascript - React - 从目标中获取值(value)

转载 作者:行者123 更新时间:2023-11-30 20:13:22 24 4
gpt4 key购买 nike

<分区>

我想从输入中获取值,但我仍然收到“无法读取未定义的属性‘目标’”,我不知道为什么它不起作用。如果有人能解释我将不胜感激

import React from "react";

class Search extends React.Component {
constructor(display) {
super(display);
this.state = {
searchingText: ""
};
}

handleChange(event) {
let searchingText = event.target.value;
this.setState({
searchingText: searchingText
});
if (searchingText.length > 2) {
this.props.onSearch(searchingText);
}
}

handleKeyUp(event) {
if (event.keyCode === 13) {
this.props.onSearch(this.state.searchingText);
}
}

render() {
const styles = {
fontSize: "1.5em",
width: "90%",
maxWidth: "350px"
};
return (
<input
type="text"
onKeyUp={this.handleKeyUp}
onChange={() => this.handleChange()}
placeholder="Tutaj wpisz fraze"
style={styles}
value={this.state.searchTerm}
/>
);
}
}

导出默认搜索;重新

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com