React native 如何从react native render html中删除标记?
如何删除只有React native 如何从react native render html中删除标记?,react-native,expo,react-native-render-html,React Native,Expo,React Native Render Html,如何删除只有标记的h2标记 您可以使用alterChildrenprop删除一些DOM节点: const html=` 你好,世界 同侧眼睑 `; 函数HASONLYBCHILDREN(节点){ 返回node.children.every( (child)=>child.type=='tag'&&child.name=='br' ); } 函数子节点(节点){ 返回node.children.filter( (儿童)=> child.type!=“标记”|| !(child.name=='h2
标记的h2
标记
您可以使用alterChildren
prop删除一些DOM节点:
const html=`
你好,世界
同侧眼睑
`;
函数HASONLYBCHILDREN(节点){
返回node.children.every(
(child)=>child.type=='tag'&&child.name=='br'
);
}
函数子节点(节点){
返回node.children.filter(
(儿童)=>
child.type!=“标记”||
!(child.name=='h2'和&hasOnlyBrChildren(child))
);
}
导出默认函数App(){
返回(
);
}
我在这里做了一个点心(我刚刚用
div
替换了br
,以直观地评估函数的有效性):您可以使用alterChildren
道具删除一些DOM节点:
const html=`
你好,世界
同侧眼睑
`;
函数HASONLYBCHILDREN(节点){
返回node.children.every(
(child)=>child.type=='tag'&&child.name=='br'
);
}
函数子节点(节点){
返回node.children.filter(
(儿童)=>
child.type!=“标记”||
!(child.name=='h2'和&hasOnlyBrChildren(child))
);
}
导出默认函数App(){
返回(
);
}
我在这里做了一份点心(我刚刚用
div
替换了br
,以直观地评估功能的有效性):我的建议解决了你的问题吗?如果是这样的话,为了社区的利益,请确认答案:-)我的提议解决了你的问题吗?如果是这样,请为社区利益确认答案:-)