[英]react native RenderHtml
我使用 RenderHtml 在移动应用程序中显示包含 html 标签的信息。 只有我想让不可点击的链接无法重定向。
我已经尝试使用 pointerEvent,但它不再被原生 React 风格所接受。 我向您展示我的代码,希望有人可以帮助我。 提前致谢,祝你有美好的一天。
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}
/>
我在发表这篇文章后 2 分钟找到了解决方案...
我用 a.replace 替换为:
setShortDescription(
data["short_description"].replace(
/<a\b[^>]*>(.*?)<\/a>/i,
"<span>$1</span>"
)
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.