【问题标题】:looking for render function will take HTML and apply styles to the string with react js寻找渲染函数将采用 HTML 并使用 react js 将样式应用于字符串
【发布时间】:2020-06-04 01:21:54
【问题描述】:

我有一个 antd 表,我正在尝试将包含 html 属性字符串的结果字段值转换为其中一列的相应样式,但该转换失败

下面是我要转换的字符串

The exhaust air requirements for fume hoods will be based on maintaining a face velocity of <b>[100] [80] [60]</b> fpm through the open sash with the sash <b>[100% open] [50% open] [positioned at 18" above work surface]</b>

我正在寻找以下类型的字符串

通风柜的排气要求将基于保持 [100] [80] [60] fpm 通过打开窗扇的面速度 [100% 打开] [50% 打开] [位于工作表面上方 18 英寸处]

但在表格中看起来像下图

任何人都可以就这个问题提出建议或任何帮助,非常感谢我,非常感谢提前

我正在使用react JS 和 ANTD 库,下面是表格的列配置

{
  title: 'Narrative Description',
  name: 'exhaustEquipmentNarrativeHTML',
  table: {
    sortable: SORTABLE.ALPHA,
    searchable: true,
    width: '20%'
    render: text => {
      return ''; // this is where i am stuck in 
    }
  },
  drawer: {
    component: JoditAdapter,
    isReadOnly: false
  }
},

【问题讨论】:

    标签: javascript html reactjs ecmascript-6 antd


    【解决方案1】:

    According to docs render can return ReactNode

    And it looks like you want to use dangerouslySetInnerHTML

    render: text => {
          return <span dangerouslySetInnerHTML={{__html: text}}></span>
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-01
      • 2018-01-20
      • 2018-11-26
      • 1970-01-01
      • 2017-01-04
      • 1970-01-01
      • 2018-08-30
      • 2012-08-20
      相关资源
      最近更新 更多