如何解决找不到模块:无法解析“react-google-charts/dist/types”
我正在开发 React 应用程序,其中我使用了 React 谷歌图表来显示带注释的折线图。但是我遇到了折线图中列的角色属性问题,已经在工作组件中导入了 react-google-charts。下面是我的代码:
Home.tsx > 组件
import * as React from 'react';
import { Chart } from 'react-google-charts';
import GoogleDataTableColumnRoleType from 'react-google-charts/dist/types';
export class Home extends React.Component<IChildComponentProps,AddDataState> {
constructor(props) {
super(props);
public render() {
<div id="chart_div2">
<Chart
width={400}
height={'300px'}
chartType="LineChart"
loader={<div>Loading Chart</div>}
rows={this.state.o3TargetChart}
columns={[
{
type: "string",label: "Week"
},{
type: "number",label: "O3Done"
},{
type: "string",role: GoogleDataTableColumnRoleType.annotation // getting error here
},label: "Target"
}
]}
options={{
title: '',hAxis: {
title: 'Week',titleTextStyle: {
},baselineColor: '#cccccc'
},vAxis: {
title: 'O3 Coverage ( in %)',minValue: 0,maxValue: 100,baselineColor: '#cccccc',},pointsVisible: true,chartArea: {
left: 100
},height: 400,width: 1000,}}
/>
</div>
}
}
虽然我可以在 node_modules 目录下找到 type 模块如下:
node_modules\react-google-charts\dist\types.d.ts
已经按照其他人的建议在 webpack.config.js 文件中添加了以下代码:
resolve: {
extensions: ['','.js','.jsx']
},
我仍然收到找不到模块的错误。请建议..
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。