vue项目使用echart,报错Error in mounted hook: “TypeError: Cannot read properties of undefined (reading ini
踩坑,在vue中使用echart绘制图表的时候报错Error in mounted hook: "TypeError: Cannot read properties of undefined (readinginit )"解决办法1、导入包的方式不对,使用官方新的导入方式。原来导入方式import echarts from 'echarts';更新导入方式为import * as echarts
·
踩坑,在vue中使用echart绘制图表的时候报错Error in mounted hook: "TypeError: Cannot read properties of undefined (reading init )"解决办法
1、导入包的方式不对,使用官方新的导入方式。
- 原来导入方式
import echarts from 'echarts';
- 更新导入方式为
import * as echarts from 'echarts';
2、默认的安装方式安装的是最新版本,太新的版本不稳定,降级。
- 卸载原来的包
npm uninstall echarts
- 查询可安装的版本
C:\Users\admin>npm view echarts versions --json
[
"2.2.1-amd-beta1",
"2.2.7-amd-beta1",
"2.2.7-amd-beta2",
"2.2.7-beta7",
"2.2.8",
"3.0.0-beta1",
"3.0.0-beta2",
"3.0.0-beta3",
"3.0.0-beta4",
"3.0.0",
"3.0.1",
"3.0.2-beta1",
"3.0.2-beta2",
"3.0.2-beta3",
"3.1.1",
"3.1.2",
"3.1.3",
"3.1.4",
"3.1.5",
"3.1.6",
"3.1.7",
"3.1.8",
"3.1.9",
"3.1.10",
"3.2.0",
"3.2.1",
"3.2.2",
"3.2.3",
"3.3.0",
"3.3.1",
"3.3.2",
"3.4.0",
"3.5.0",
"3.5.1",
"3.5.2",
"3.5.3",
"3.5.4",
"3.6.0",
"3.6.1",
"3.6.2",
"3.7.0",
"3.7.1",
"3.7.2",
"3.8.0",
"3.8.1",
"3.8.2",
"3.8.3",
"3.8.4",
"3.8.5",
"4.0.0",
"4.0.1",
"4.0.2",
"4.0.3",
"4.0.4",
"4.1.0",
"4.2.0-rc.1",
"4.2.0-rc.2",
"4.2.1-rc.1",
"4.2.1-rc.2",
"4.2.1-rc.3",
"4.2.1",
"4.3.0-rc.1",
"4.3.0-rc.2",
"4.3.0",
"4.4.0-rc.1",
"4.4.0",
"4.5.0-rc.1",
"4.5.0-rc.2",
"4.5.0",
"4.6.0",
"4.7.0",
"4.8.0",
"4.9.0",
"5.0.0-alpha.1",
"5.0.0-alpha.2",
"5.0.0-beta.1",
"5.0.0-beta.2",
"5.0.0-rc.1",
"5.0.0",
"5.0.1",
"5.0.2",
"5.1.0",
"5.1.1",
"5.1.2",
"5.2.0",
"5.2.1",
"5.2.2",
"5.3.0-rc.1",
"5.3.0",
"5.3.1-rc.1",
"5.3.1",
"5.3.2-rc.1",
"5.3.2"
]
- 安装指定版本
npm install echarts@5.2.2 --save
注意事项,降级之后重启项目,热部署可能检测不到包的变化。
更多推荐
已为社区贡献1条内容
所有评论(0)