react中的ref的使用

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/pansuyong/article/details/82758707
<ul ref={(su)=>{this.ul=su}}>
    {this.getTodoItem()}
</ul>
handleBtnClick(){
    this.setState((prevState)=>({
            list: [...prevState.list,prevState.inputValue],
            inputValue:""
    }),()=>{
        console.log("999:",this.ul.querySelectorAll('div').length);
    })
}

猜你喜欢

转载自blog.csdn.net/pansuyong/article/details/82758707