如何在material-ui TextField中突出显示部分文本

时间:2019-10-18 08:12:45

标签: reactjs material-ui

我要突出显示而不是选择 [error] 4044#0: *1068056 attempt to send data on a closed socket组件中值的一部分

类似这样的东西

enter image description here

我尝试将一个TextField与一个类一起使用在值prop中,但是却显示了<span>

我该如何实现?

2 个答案:

答案 0 :(得分:0)

材料UI文本字段组件基本上由html输入组件组成。

Textfield“值”属性将反映为html输入元素的值

HTML in the input field value

答案 1 :(得分:0)

是的,可以突出显示,但是我们需要将文本预先解析为html

警告!必须注意文本的来源。

npm install html-react-parser

var parse = require('html-react-parser');
<Typography > {parse(props.text)}</Typography>

示例: props.text =“这应该呈现您的html”