echarts 使用时候报错:init方法
export 'default' (imported as 'echarts') was not found in 'echarts' Cannot read property 'init' of undefined
这种原因是你安装了5.0以上版本的echarts。
1.卸载5.0以上版本的echarts
npm uninstall echarts
2.安装指定版本的echarts
npm install [email protected]
这里安装5.0以下版本都行,之后就是正常操作了。。。。。。
3. main.js入口文件对组件进行全局配置
// 引入 echarts 插件 import echarts from 'echarts' // 配置成全局组件 Vue.prototype.$echarts = echarts
<template> <div id="chartColumn" style="width: 100%; height: 400px;"> </div> </template> <script> import echarts from 'echarts' export default { data(){ return { chartColumn: null } }, mounted() { this.drawLine(); }, methods: { drawLine(){ this.chartColumn = echarts.init(document.getElementById('chartColumn')); this.chartColumn.setoption({ title: { text: 'Column Chart' }, tooltip: {}, xAxis: { type: 'category', data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, yAxis: { type: 'value' }, series: [{ data: [820, 932, 901, 934, 1290, 1330, 1320], type: 'line' }] }); } } } </script>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。