此处我正在使用此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'
}
]
});
}