我正在编写一个基于 React 的应用程序,其中一个组件将其 HTML 内容作为 props 中的字符串字段接收。此内容由 API 调用返回。
我需要:
例如,如果我收到下面的 HTML,我应该在 ID 为“s101”的部分旁边显示“评论”按钮。
<html>
<head/>
<body>
<div id="content">
<section id="s101" accept-comments="true">Some text that needs comments</section>
<section id="s102">Some text that doesn't need comments</section>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
问题:
我尝试过的事情: