【问题标题】:React make part of prop bold inside a componentReact 使组件内的部分道具变为粗体
【发布时间】:2019-02-05 12:05:34
【问题描述】:

有没有办法使包含字符串的概率部分变为粗体? 我已经尝试过数组方法,但我听说它不是正确的方法

<ListItemText primary={thread.data.title} secondary={"Author: " + thread.data.author} />

我希望“作者:”加粗

【问题讨论】:

    标签: reactjs components


    【解决方案1】:

    React 中的 props 可以是任何东西:函数、字符串、对象和...JSX 试试:

    <ListItemText 
      primary={thread.data.title} 
      secondary={<span><b>Author</b>{thread.data.author}</span>} />

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-07-28
      • 1970-01-01
      • 2012-08-18
      • 1970-01-01
      • 2022-08-19
      • 1970-01-01
      • 2021-06-26
      • 1970-01-01
      相关资源
      最近更新 更多