[英]react native RenderHtml
I use RenderHtml to display information containing html tags in a mobile application.我使用 RenderHtml 在移动应用程序中显示包含 html 标签的信息。 Only I would like to make the non-clickable, make redirection of these links impossible.
只有我想让不可点击的链接无法重定向。
I already tried to use pointerEvent but it is not accepted in the native react style anymore.我已经尝试使用 pointerEvent,但它不再被原生 React 风格所接受。 I show you my code hoping someone can help me with this.
我向您展示我的代码,希望有人可以帮助我。 Thanks in advance and have a nice day.
提前致谢,祝你有美好的一天。
const onLinkPress = () => {};
const short_description = {
html: shortDescription,
};
const tagsStyles = {
body: {
whiteSpace: "normal",
color: "gray",
width: width * 0.7,
margin: 20,
top: 5,
right: 3,
},
a: {
color: "gray",
textDecorationLine: "none",
href: "",
},
};
<RenderHtml
onLinkPress={onLinkPress}
contentWidth={(width, height)}
source={short_description}
tagsStyles={tagsStyles}
/>
I found the solution 2 min after make this post...我在发表这篇文章后 2 分钟找到了解决方案...
I used a.replace to replace by:我用 a.replace 替换为:
setShortDescription(
data["short_description"].replace(
/<a\b[^>]*>(.*?)<\/a>/i,
"<span>$1</span>"
)
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.