老師 哪裡可以改善
来源:2-7 自由编程
weixin_慕雪0272820
2020-08-23 21:50:26
import React, { Component, Fragment } from 'react';
class Ref extends Component {
constructor(props) {
super(props);
this.getContent = this.getContent.bind(this);
this.state = {
content:""
}
}
getContent() {
let content = this.inputElement.value
console.log(content)
this.setState({content})
}
render() {
return (
<Fragment>
<input ref={(ref) => this.inputElement = ref}/><br/>
<button onClick= {this.getContent}>提交</button>
</Fragment>
)
}
}
export default Ref1回答
同学你好,效果是正确的,不用改善了,继续加油,祝学习愉快~
相似问题