【发布时间】:2021-09-13 22:33:39
【问题描述】:
我的 next.js 项目中有这段代码,我使用 react-chartjs-2 库来创建图表。 chart.js 中的 cutoutPercentage 属性理论上使圆环图更薄,但在 next.js 中它不起作用。 我怎样才能让它工作?
import { Doughnut } from 'react-chartjs-2';
const data = {
datasets: [
{
data: [15, 12, 40, 30],
backgroundColor: ["#c5e99b", "#8fbc94", "#548687", "#56445d"],
},
],
};
const Options = {
tooltips: {
enabled: false,
},
cutoutPercentage: 70,
responsive: true,
maintainAspectRatio: false,
}
export default () => (
<Doughnut
data={data}
width={290}
height={290}
options={Options}
/>
);
【问题讨论】:
-
它是否在服务器上显示文档/窗口未定义的错误?
-
没有服务器或客户端没有错误
-
给export comp命名并使用它来导入组件。 const DynamicComponentWithNoSSR = dynamic(() => import('../components/hello3'),{ ssr: false })
标签: reactjs next.js chart.js react-chartjs-2