【发布时间】:2021-09-12 15:32:09
【问题描述】:
我的公共文件夹中有一个静态 JSON 文件,我想在 React (NextJS) 组件中输出内容。只需再次将所有内容显示为 JSON。
import data from '../../public/static/somedata/data.json';
const DummyComponent = () => {
return (
<div className="box">{data}</div>
);
};
目前我收到错误:
对象作为 React 子对象无效
有没有办法在 React 组件中显示原始 JSON 内容?
【问题讨论】:
标签: json reactjs typescript react-redux next.js