<p ref="stringRef"></p>
this.$refs.stringRef.textContent
<p ref={ ele => ( this.aaaRef = ele)}></p> // ele就是当前实例
this.aaaRef.textContent
constructor(){
this.objRef = React.createRef();
// { current: null }
}
this.objRef.current.textContent
<p ref={this.objRef}></p>
========
forwardRef
const NextComponet = React.forwardRef((props, ref) => (
<input type="text" ref={ref} />
))
class Comp extends React.Component{
constructor(){
super();
this.ref = React.createRef();
}
componentDidMount(){
this.ref.current.value = 'ref!!!'
}
render(){
return <NextComponet ref={this.ref} />
}
}
var arr = ["1","2","3"];
arr.map((value,index,array) => parseInt(value,index));