Jay*_*odi 16 javascript markdown npm reactjs strapi
目前我正在使用"react": "17.0.2"并且已经安装"react-markdown": "^7.0.1"通过npm i react-markdown我正在使用这个包来显示我从 Strapi CMS 获取的富文本。我使用以下代码来显示内容:
import ReactMarkdown from "react-markdown";
export default function name({ posts }) {
return (
<>
<div>
<div>
{posts.Title}
</div>
</div>
<div>
<ReactMarkdown source={posts.Content} escapeHtml={false} />
</div>
</>
);
}
export async function getStaticProps() {
const res = await fetch("http://localhost:1337/blogs");
const posts = await res.json();
return {
props: { posts },
};
}
Run Code Online (Sandbox Code Playgroud)
但是当我运行它时,它给了我以下错误:
我正在使用节点v14.17.0并尝试添加"type": "module".
我的package.json:
import ReactMarkdown from "react-markdown";
export default function name({ posts }) {
return (
<>
<div>
<div>
{posts.Title}
</div>
</div>
<div>
<ReactMarkdown source={posts.Content} escapeHtml={false} />
</div>
</>
);
}
export async function getStaticProps() {
const res = await fetch("http://localhost:1337/blogs");
const posts = await res.json();
return {
props: { posts },
};
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11251 次 |
| 最近记录: |