我正在获取一个API,它用带有CSS道具的样式标记来响应预先格式化的HTML文件,最重要的是,在需要提取信息的地方定义ID标记,以绘制一个与我正在获得的可怕的HTML不同的反应性UI组件,该html当前正在用html- React解析器呈现为iframe。
<div class="App" style="text-align: center;">
<h1 #text1_to_extract>html-react-parser</h1>
<p >
<a
href="https://github.com/remarkablemark/html-react-parser"
target="_blank"
rel="noopener noreferrer"
#text2_to_extract
>
View GitHub repository
</a>
</p>
<hr class="remove">
</div>如何提取这个#id中的文本并直接解析到一个JSX标记?
发布于 2022-06-01 02:01:01
试试下面的代码:
const collection = document.getElementsByTagName("h1");
const idText = collection[0].id;在idText变量中,您将在id中找到文本。
https://stackoverflow.com/questions/72455256
复制相似问题