大螃嗨

好记性不如烂笔头

用户工具

站点工具


inputref
onSelectionChange(e) {
    const { selectionStart, selectionEnd, value } = e.target;
 
    this.setState(
      {
        selStart: selectionStart,
        selEnd: selectionEnd,
        selValue: value.substring(selectionStart, selectionEnd),
      },
      () => {
        console.log('this.state.selStart');
        console.log(this.state.selStart);
      },
    );
  }
 
<Textfield 
onMouseUp={this.onSelectionChange}
inputRef={(ref)=>{this.inputRef = ref;}} />
inputref.txt · 最后更改: 2020/06/16 04:01 由 螃蟹