当我在 React JS 中从 API 调用 CK Editor returns <p> 标签而不是整个内容时
CK Editor returns <p> tags instead of whole content when i call it from API in React JS
我正在使用 React 和 Strapi 构建应用程序,并使用 CKEditor 5 添加一篇文章作为内容。
在编辑器中它一切正常它接受标题粗体段落但是当我在前端阅读它时它只是在 <p>
标签
中提供内容包装
这是我的CKEditor输入代码
<CKEditor
name="longContent"
editor={ClassicEditor}
data={modifiedData.longContent}
onChange={this.handleCKchange}
/>
onChnage 处理程序
handleCKchange = (event, editor) => {
const data = editor.getData();
this.state.modifiedData.longContent = data;
};
我在前端是这样称呼它的
<div className="post-longContent">
{modifiedData.longContent}
</div>
这是它的输出方式
duplicate。以前我使用 dangerouslySetInnerHTML 但我认为不推荐使用。
我正在使用 React 和 Strapi 构建应用程序,并使用 CKEditor 5 添加一篇文章作为内容。
在编辑器中它一切正常它接受标题粗体段落但是当我在前端阅读它时它只是在 <p>
标签
这是我的CKEditor输入代码
<CKEditor
name="longContent"
editor={ClassicEditor}
data={modifiedData.longContent}
onChange={this.handleCKchange}
/>
onChnage 处理程序
handleCKchange = (event, editor) => {
const data = editor.getData();
this.state.modifiedData.longContent = data;
};
我在前端是这样称呼它的
<div className="post-longContent">
{modifiedData.longContent}
</div>
这是它的输出方式
duplicate。以前我使用 dangerouslySetInnerHTML 但我认为不推荐使用。