Taro: <Text>我是\n换行符 </Text> 在微信小程序和H5表现不一致

Created on 16 Jan 2019  ·  4Comments  ·  Source: NervJS/taro

我是\n换行符 在微信小程序和H5表现不一致

微信小程序\n可以换行
但是h5显示 为 \n字符串,并没有换行

dev模式下
taro版本
Taro v1.2.7

Taro CLI 1.2.7 environment info:
System:
OS: macOS High Sierra 10.13.6
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 8.1.0 - /usr/local/bin/node
npm: 6.4.1 - /usr/local/bin/npm
npmPackages:
@tarojs/async-await: 1.2.7 => 1.2.7
@tarojs/cli: 1.2.7 => 1.2.7
@tarojs/components: 1.2.7 => 1.2.7
@tarojs/plugin-babel: 1.2.7 => 1.2.7
@tarojs/plugin-csso: 1.2.7 => 1.2.7
@tarojs/plugin-less: 1.2.7 => 1.2.7
@tarojs/plugin-sass: 1.2.7 => 1.2.7
@tarojs/plugin-uglifyjs: 1.2.7 => 1.2.7
@tarojs/redux: 1.2.7 => 1.2.7
@tarojs/redux-h5: 1.2.7 => 1.2.7
@tarojs/router: 1.2.7 => 1.2.7
@tarojs/taro: 1.2.7 => 1.2.7
@tarojs/taro-h5: 1.2.7 => 1.2.7
@tarojs/taro-weapp: 1.2.7 => 1.2.7
@tarojs/webpack-runner: 1.2.7 => 1.2.7
eslint-config-taro: 1.2.7 => 1.2.7
eslint-plugin-taro: 1.2.7 => 1.2.7

question

Most helpful comment

h5 是否换行是由 css 控制的,textarea 可以用 \n 换行,Text 的实现是 span 是无法做到换行的。

你可以这样:


<Text>我是 { process.env.TARO_ENV === 'h5' ? <br /> : '\n' }换行符 </Text>

All 4 comments

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

build和dev 模式下 微信小程序 我是\n换行符 可以换行
build和dev 模式下 h5 我是\n换行符 没有换行 显示为\n

h5 是否换行是由 css 控制的,textarea 可以用 \n 换行,Text 的实现是 span 是无法做到换行的。

你可以这样:


<Text>我是 { process.env.TARO_ENV === 'h5' ? <br /> : '\n' }换行符 </Text>

Hello~

您的问题楼上已经有了确切的回答,如果没有更多的问题这个 issue 将在 15 天后被自动关闭。

如果您在这 15 天中更新更多信息自动关闭的流程会自动取消,如有其他问题也可以发起新的 Issue。

Good luck and happy coding~

Was this page helpful?
0 / 5 - 0 ratings

Related issues

qilovehua picture qilovehua  ·  3Comments

aiewing picture aiewing  ·  3Comments

chankamlam picture chankamlam  ·  3Comments

zhuxianguo picture zhuxianguo  ·  3Comments

LadyChatterleyLover picture LadyChatterleyLover  ·  3Comments