我正在做本机项目。
我们正在以Json数据的形式获得问题和解答。对于答案,我们在答案键中获取HTML内容。
所以,我必须在列表中显示答案的数量。 无论如何,是否可以不使用Webview来呈现HTML内容?
Json类似于以下示例:
[ { question: 'How do I change or reset my password?',
answer: <p style="color:#B22222">Color text and <span style="color:limegreen;">another color</span>, and now back to the same. Oh, and here's a <span style="background-color:PaleGreen;">different background color</span> just in case you need it!</p>
},
{ question: 'How do I change my user name?',
answer: <p>Here's a blockquote:</p>
<blockquote>Contents should not be swallowed. This is due to the enormous amount of harmful chemicals that has gone into this burger.</blockquote>
<p>That was a blockquote.</p>
},
{ question: 'How do I change my email ID?',
answer:<p style="font-size:18pt">Text size using points.</p><p style="font-size:18px">Text size using pixels.</p><p style="font-size:larger">Text size using relative sizes.</p>
},
....
]
数据是动态的,并且答案和问题也不同。
任何建议,在不使用Webview的情况下,我们可以将HTML内容呈现到平面列表中以供循环使用。
答案 0 :(得分:0)
...
import HTML from 'react-native-render-html';
...
<HTML tagsStyles={{
p: styles.textAuthor}}
html={htmldata}
imagesMaxWidth={screen.screenWidth}
/>
使用此库,您可以在呈现之前操纵HTML节点。