在我的项目中,我使用WebView
的react native加载html内容。但是问题是我在结果中得到了不需要的字符。我的意思是html内容包含 
这些会以响应本机的形式呈现为一些不需要的字符以及文本。我试过regex
来删除它,但不起作用。以下是我的代码,请帮忙。
代码
<Content contentContainerStyle={{ flex: 1}}>
{this.state.data.map(item =>
<View style={{flex:1,padding:10}}>
<Text style={{textAlign:'center', margin:15,fontSize:20,fontWeight:'bold'}}>{item.data.course.name}</Text>
<WebView
source={{ html: item.data.description.replace(/^\s* /m, '') + htmlStyle }}
javaScriptEnabled={true}
/>
</View>
)}
</Content>
以下是屏幕截图
json
data:
course: {id: 5506, name: "Balance of Payment Account: Meaning and Significance"}
curriculum: false
description: "<p style="text-align: justify;"><strong>Guide to the module: </strong></p>↵<p style="text-align: justify;"> This module deals with the balance of payment account concepts from the Indian context. At the later part, a typical balance of payment scenario of India is illustrated by taking 2012-13 financial year as an example.</p>↵<p style="text-align: justify;"><strong>Balance of payment account</strong></p>↵<p style="text-align: justify;"> Balance of payment systematically shows the whole types of economic engagement between residents of India and the residents of the rest of the world. The transaction details are usually shown for a period (like one year).