【问题标题】:How can I remove whitespace from a string in react-native?如何从 react-native 中的字符串中删除空格?
【发布时间】:2021-09-11 07:55:17
【问题描述】:

我正在使用 react-native。但是,当输入长字符串时,右屏换行不一致。

喜欢这个

但是,我希望字符串能够像下图一样自动换行。

这是我的代码,我该如何修复或添加代码??

    import React from 'react';
    import styled from 'styled-components/native';

    const Container = styled.View`
      background: lightskyblue;
      width: 100%;
      height: 100%;
    `;

    const PolicyContainer = styled.View`
      background: lightyellow;
    `;

    const Label = styled.Text`
      font-size: 13px;
    `;
    const Policy = () => {
      return (
        <Container>
          <PolicyContainer>
            <Label>
              {'<'}example{'>'}('https://example'이하 'example')은(는) 「개인정보
              보호법」 제30조에 따라 정보주체의 개인정보를 보호하고 이와 관련한
              고충을 신속하고 원활하게 처리할 수 있도록 하기 위하여 다음과 같이
              개인정보 처리방침을 수립·공개합니다.
            </Label>
          </PolicyContainer>
        </Container>
      );
    };

    export default Policy;

【问题讨论】:

    标签: javascript node.js reactjs react-native styled-components


    【解决方案1】:

    尝试以Label 的样式使用text-align: justify;。我相信它会解决你的问题。

    const Label = styled.Text`
      font-size: 13px;
      text-align: justify;
    `;
    

    【讨论】:

      猜你喜欢
      • 2021-09-04
      • 2020-02-02
      • 2017-11-20
      • 2011-09-21
      • 2018-03-13
      相关资源
      最近更新 更多