老师。这样可以吗

来源:2-7 自由编程

慕仙本仙_

2020-05-28 15:41:24

import React,{ Component,Fragment} from 'react'

import Child from './child.js'

class Counter extends Component{

constructor(props){

super(props);

this.handleBtnClick=this.handleBtnClick.bind(this);

this.state={

content:''

}

}

handleBtnClick(){

var newCountent=this.inputElem.value;

console.log(newCountent);

this.inputElem.value='';

}

render(){

return (

<Fragment>

<input ref={(input)=>{this.inputElem=input}} />

      <button onClick={this.handleBtnClick}>提交</button>

     

    </Fragment>

    )

}

}

export default Counter;


写回答

1回答

好帮手慕星星

2020-05-28

同学你好,代码实现效果很棒,没有问题。继续加油,祝学习愉快~

0

0 学习 · 10739 问题

查看课程