首页 > 解决方案 > 如何将 chart.js 3+ 导入 React 应用程序?

问题描述

我在将 chart.js 导入我的应用程序时遇到了问题,而在版本 2+ 中它很简单:

import Chartjs from 'chart.js';

现在这不再起作用了。

Attempted import error: 'chart.js' does not contain a default export (imported as 'Chartjs').

标签: javascriptreactjscharts

解决方案


我想你必须像这样导入它: import { Chart } from 'chart.js';

更多信息请访问: https ://www.chartjs.org/docs/latest/getting-started/integration.html


推荐阅读