小编min*_*dis的帖子

是否可以在 antd 表中显示 html 格式的文本?

我的后端服务(elasticsearch percolator)使用 html 标签注释文本以突出显示匹配项。

我找不到在 antd Table 中显示此类 html 数据的方法。

我试过 Highlighter 组件,但它将关键字应用于整列,但我需要在每一行中突出显示不同的单词。

链接到小提琴

const { Table } = antd

class TableColor extends React.Component {
  constructor (props) {
    super(props)

    this.state = {
        data: []
    }
  }

  componentDidMount() {
    this.setState({
        data: [
        {id:1, name: 'Lazy < bclass="myBackgroundColor">fox</b>', match: 'fox'},
        {id:2, name: '<b class="myBackgroundColor">Dog</b> runs', match: 'Dog'},
        {id:3, name: 'I saw <b class="myBackgroundColor">duck</b>', match: 'duck'}
      ]
    })
  }

  render () {
   const columns = [{
      title: 'ID',
      dataIndex: 'id',
    }, {
      title: …
Run Code Online (Sandbox Code Playgroud)

reactjs antd

5
推荐指数
1
解决办法
3713
查看次数

标签 统计

antd ×1

reactjs ×1