【发布时间】:2016-02-05 09:56:01
【问题描述】:
我目前面临一个挑战,我必须使用这样的纯 HTML 响应 API:
<div class="yx"><h3>SomeHead</h3><div class="otherclass"><p>someText</p></div><span class="time">23123123</span></div><div class="yx"><h3>SomeHead</h3><div class="otherclass"><p>someText</p></div><span class="time">23123123</span></div><div class="yx"><h3>SomeHead</h3><div class="otherclass"><p>someText</p></div><span class="time">23123123</span></div>
因为我需要在我的原生应用程序中显示这些信息,所以我不得不用原生的 HTML 语法替换所有的 HTML 语法。 在尝试了一些自己编写的函数后,我设法获得了一个看似正确的方法,它将所有内容转换为以下输出:(数组)
0: "<View><Text>SomeHead</Text><View><Text>someText</Text></View><Text>41234123</Text></View>"
1: "<View><Text>SomeHead</Text><View><Text>someText</Text></View><Text>41234123</Text></View>"
3: "<View><Text>SomeHead</Text><View><Text>someText</Text></View><Text>41234123</Text></View>"
现在我需要设法以正确的语法将该字符串输出到我的应用程序中 - 不幸的是,我仍在努力寻找合适的解决方案。
JSON. 方法不起作用,因为它们只能处理 JSON 语法,而 < 不在其支持范围内
注意回复的内容不是实际内容,而是代表我的情况。
【问题讨论】:
标签: javascript reactjs react-native