vue项目使用echart,报错Error in mounted hook: “TypeError: Cannot read properties of undefined (reading ini

阅读: 评论:0

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 (reading ini

踩坑,在vue中使用echart绘制图表的时候报错Error in mounted hook: "TypeError: Cannot read properties of undefined (reading init )"解决办法

1、导入包的方式不对,使用官方新的导入方式。

  1. 原来导入方式
import echarts from 'echarts';
  1. 更新导入方式为
import * as echarts from 'echarts';

2、默认的安装方式安装的是最新版本,太新的版本不稳定,降级。

  1. 卸载原来的包
npm uninstall echarts
  1. 查询可安装的版本
C:Usersadmin>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"
]
  1. 安装指定版本
npm install echarts@5.2.2 --save

注意事项,降级之后重启项目,热部署可能检测不到包的变化。

本文发布于:2024-02-05 05:35:46,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170725322463484.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:报错   项目   Error   mounted   echart
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23