We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
如果 Html 字符串中出现仅包含 <br/> 的元素,形如:
<br/>
<p><br/></p> <p style="text-indent:2em;"><br/></p>
被解析出来的 Dom 节点结构如下: [{ ... "children": [{ "name": "br", "attrs": {} }] }]
此时在百度开发者工具中的模拟器里可以正常显示解析后的富文本,但是在真机预览时,包含这部分 Dom 节点的节点会整个 被百度自带的 <rich-text> 组件去除,导致文本内容显示不全。
<rich-text>
百度开发者工具模拟器中显示完整:
真机APP预览中所有此类段落都被删除:
我暂时通过向 mp-html\index.js 中的 setContent: function (e, n) {} 函数添加 e = e.replace(/<(\w+)([^>]*)><br\/><\/\1>/ig,'') 正则表达式,将仅包含<br/> 的元素全部删除解决了这个问题。 不知道有没有人遇到和我一样的问题,或者有什么更好的解决方法?
mp-html\index.js
setContent: function (e, n) {}
e = e.replace(/<(\w+)([^>]*)><br\/><\/\1>/ig,'')
The text was updated successfully, but these errors were encountered:
找到问题了,br 解析结果里有一个 undefined,可能导致了真机上异常,我修改一下
br
undefined
Sorry, something went wrong.
修复了百度小程序使用 br 标签可能部分不显示的问题 #409
20094da
感谢大佬。
No branches or pull requests
问题描述
如果 Html 字符串中出现仅包含
<br/>
的元素,形如:此时在百度开发者工具中的模拟器里可以正常显示解析后的富文本,但是在真机预览时,包含这部分 Dom 节点的节点会整个
被百度自带的
<rich-text>
组件去除,导致文本内容显示不全。百度开发者工具模拟器中显示完整:
真机APP预览中所有此类段落都被删除:
解决办法
我暂时通过向
mp-html\index.js
中的setContent: function (e, n) {}
函数添加e = e.replace(/<(\w+)([^>]*)><br\/><\/\1>/ig,'')
正则表达式,将仅包含<br/>
的元素全部删除解决了这个问题。不知道有没有人遇到和我一样的问题,或者有什么更好的解决方法?
The text was updated successfully, but these errors were encountered: