如何在React项目中使用Highcharts Flowmap与typescript

new9mtju  于 2023-10-20  发布在  Highcharts
关注(0)|答案(1)|浏览(156)

我想得到一个类似的图表在React项目使用typescript-https://www.highcharts.com/demo/maps/flowmap
flowmap模块在highcharts中以.js文件的形式出现,而不是.ts文件。
因此,连接模块的尝试

import HighchartsMap from 'highcharts/highmaps';
import HighchartsReact from 'highcharts-react-official';
import HighchartsFlowmap from 'highcharts/modules/flowmap'

HighchartsFlowmap(HighchartsMap);

return <HighchartsReact highcharts={HighchartsMap} options={options} constructorType='mapChart' />;

导致错误:

TS7016: Could not find a declaration file for module 'highcharts/modules/flowmap'. '.../node_modules/highcharts/modules/flowmap.js' implicitly has an 'any' type.
  If the 'highcharts' package actually exposes this module, try adding a new declaration (.d.ts) file containing `declare module 'highcharts/modules/flowmap';`

请告诉我如何解决这个问题

o2g1uqev

o2g1uqev1#

流程图系列可从Highcharts 11v获得。请确保您使用正确的版本。
加载模块的替代方法:

require('highcharts/modules/flowmap')(Highcharts)

Demo:https://stackblitz.com/edit/react-ts-c8vikm?file=package.json,index.tsx,index.html

相关问题