我如何在textarea reactjs引导程序中突出显示文本

时间:2020-04-13 08:24:28

标签: javascript reactjs twitter-bootstrap

此处我正在使用此jquery Highlight_within_textarea link 这是我的文本区域

<textarea className="form-control"
      spellcheck="false"
      placeholder="enter"
       id="exampleFormControlTextarea1" rows={4} 
       style={{fontSize: '20px',strong:{
        color:'#b1b1b1',
       fontSize:18,
      }}}
       onChange={this.handleChange}
       value={this.state.input}
       />

这是我的反应handleChange updateHighlights

    handleChange(text){
    this.setState({input:text.target.value});
     this.updateHighlights();
  }
  updateHighlights() {
    $('#exampleFormControlTextarea1').highlightWithinTextarea({
      highlight: [
        {
            highlight: 'strawberry',
            className: 'red'
        },
        {
            highlight: 'blueberry',
            className: 'blue'
        },
        {
            highlight: /ba(na)*/gi,
            className: 'yellow'
        }
    ]
  });
  }

预期输出 this 我得到什么 this

0 个答案:

没有答案
相关问题