Wordpress WP API和React呈现HTML,而不是文本

Wordpress WP API和React呈现HTML,而不是文本,wordpress,reactjs,Wordpress,Reactjs,我正在创建一个博客。现在我正在发送一个JSON请求并获取所有帖子,这可以正常工作)一旦我有了这个消息,我将为每个帖子创建一个post对象 我可以正确地显示标题、图像等。但是,当我尝试使用post.content.rendered(我使用前250个字符进行预览)显示文章内容时,它会在输出中显示实际的html,而不是打印“Hello World” <p>Hello World</p> 你好,世界 我正在从:/wp json/wp/v2/posts成功获得json响应,并在

我正在创建一个博客。现在我正在发送一个JSON请求并获取所有帖子,这可以正常工作)一旦我有了这个消息,我将为每个帖子创建一个post对象

我可以正确地显示标题、图像等。但是,当我尝试使用post.content.rendered(我使用前250个字符进行预览)显示文章内容时,它会在输出中显示实际的html,而不是打印“Hello World”

<p>Hello World</p>
你好,世界

我正在从:/wp json/wp/v2/posts成功获得json响应,并在下面的代码中返回post信息

return (
    <article className="post-outer" id={post.id}>
      <section className="post-section">
        <a className="post-link">
          <div className="post-box" >
            <h1 className="post-title">
              {post.title.rendered}
            </h1>
            <p className="post-desc">
              {post.content.rendered.substring(0,250)}
            </p>
            </div>
          <figure className="media-wrapper"><img src={ this.state.media } /></figure>
        </a>
      </section>
    </article>
  )
返回(
{post.title.rendered}

{post.content.rendered.substring(0250)}

)
使用
危险的SetinenerHTML
呈现html字符串:

<div dangerouslySetInnerHTML={{ __html: post.content.rendered }} />

使用
危险的SetinenerHTML
呈现html字符串:

<div dangerouslySetInnerHTML={{ __html: post.content.rendered }} />


知道如何只显示html输出的前250个字符吗?如果您使用html字符串,那么它应该是正确的,否则它将显示为文本。检查所附的代码段:)知道如何仅显示html输出的前250个字符吗?如果使用html字符串,则应该正确,否则它将显示为文本。检查附加的代码段:)