Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

text 组件 decode 属性无效 #8549

Closed
without-yy opened this issue Jan 18, 2021 · 9 comments
Closed

text 组件 decode 属性无效 #8549

without-yy opened this issue Jan 18, 2021 · 9 comments
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x

Comments

@without-yy
Copy link

相关平台

微信小程序

复现仓库

https://github.com/without-yy/taro_onClick_issue/blob/master/src/pages/text/index.js
小程序基础库: 2.14.4
使用框架: React

复现步骤

<Text decode dangerouslySetInnerHTML={{ __html: '测试换行\nxxxx' }} />

C8piMHBIL3uswVQ

期望结果

decode可以生效

实际结果

不生效

环境信息

👽 Taro v3.0.24


  Taro CLI 3.0.24 environment info:
    System:
      OS: macOS 11.1
      Shell: 5.8 - /bin/zsh
    Binaries:
      Node: 14.15.4 - /usr/local/opt/node@14/bin/node
      Yarn: 1.22.10 - /usr/local/bin/yarn
      npm: 6.14.10 - /usr/local/opt/node@14/bin/npm
    npmPackages:
      @tarojs/cli: 3.0.24 => 3.0.24 
      @tarojs/components: 3.0.24 => 3.0.24 
      @tarojs/mini-runner: 3.0.24 => 3.0.24 
      @tarojs/react: 3.0.24 => 3.0.24 
      @tarojs/runtime: 3.0.24 => 3.0.24 
      @tarojs/taro: 3.0.24 => 3.0.24 
      @tarojs/webpack-runner: 3.0.24 => 3.0.24 
      babel-preset-taro: 3.0.24 => 3.0.24 
      eslint-config-taro: 3.0.24 => 3.0.24 
      react: ^16.10.0 => 16.14.0 
      taro-ui: ^3.0.0-alpha.3 => 3.0.0-alpha.9 

@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Jan 18, 2021
@without-yy
Copy link
Author

复现步骤截图看不到啊

科学上网

@wangfandev
Copy link

decode可以解析的有 、<、>、&、'、 、&emsp; \n换行符不支持

@honlyHuang
Copy link
Contributor

微信文档 末尾的 Bug & Tip

  1. tip: decode可以解析的有 &nbsp; &lt; &gt; &amp; &apos; &ensp; &emsp;

不支持 \n换行符

@without-yy
Copy link
Author

@honlyHuang @wangfandev

#7003 (comment)

text组件换行应该怎么写

@mosqlee
Copy link

mosqlee commented Jan 20, 2021

<Text className="test">{"测试换行\nxxxx"}</Text>

@mosqlee
Copy link

mosqlee commented Jan 20, 2021

@honlyHuang @Chen-jj

packages/taro-runtime/src/dom/html/style.ts里面直接替换html里面所有换行有问题。
我今天会提个pr,麻烦大佬们看下。https://github.com/NervJS/taro/blob/0aa75e1f89caf115cec12a6df820a4a89083f9e7/packages/taro-runtime/src/dom/html/style.ts#L37

@iSoftstone-HOS
Copy link

decode可以解析的有 、<、>、&、'、 、&emsp;

@toFrankie
Copy link
Contributor

toFrankie commented May 23, 2022

@honlyHuang @wangfandev

#7003 (comment)

text组件换行应该怎么写

看这个回答:#7003 (comment)

@toFrankie
Copy link
Contributor

使用 transformElementel.nodeName === text 的元素设置 el.setAttribute('decode', true) 不生效,咋回事呢,姿势不对??渲染后的小程序 <text> 元素并没有如预期般添加 decode 属性。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Projects
None yet
Development

No branches or pull requests

6 participants