1\首先,在项目中获取 "echarts" npm install echarts --save
2\在文件中引入 import echarts from "echarts"
3\在页面上写入Echart的元素,重要的一点是一定要写宽高样式,否则不能够正确显示
<div id="main" style="width: 600px;height:400px;"></div>
4\注册元素完成初始化,data中写入需要的option配置
![](https://img.haomeiwen.com/i6443335/14cbcf53654335db.png)
可能遇到的问题:
this.$refs.conponent.show() is not function
排查:console.log(this.$refs.conponent) ,确认是否正确获取到了组件,
如果组件正确,去排查组件中的事件是否存在(可能是methods函数本身就写错了)
网友评论