代码之家  ›  专栏  ›  技术社区  ›  assembler

材质UI CardContent不呈现跳转线

  •  1
  • assembler  · 技术社区  · 4 年前

    我有一个呈现材质UI的组件 Card ,它将接收如下字符串:

    'This
    is
    a
    test'
    

    但它使 'This is a test' 在一行中。我试过这个:

    <Card>
      <CardContent>
         <Typography noWrap>{value}</Typography>
      </CardContent>
    </Card>
    

    <Card>
      <CardContent>
         {value}
      </CardContent>
    </Card>
    

    但是,如果我 console.log(value); 然后在控制台上按预期显示消息。

    1 回复  |  直到 4 年前
        1
  •  1
  •   NearHuscarl    4 年前

    white-space: pre 要强制文本转到换行符的下一行,请执行以下操作:

    <Typography whiteSpace="pre">
    

    Codesandbox Demo