怎么配置echarts (亲测有效)
1.安装
npm install echarts --save 下载
2,在main.js中引用
import echarts from "echarts";
Vue.prototype.$echarts = echarts;
3.在需要使用的页面再次引用
var echarts = require('echarts');
4.在页面的 放一个容器
<div id="echartContainer" style="width:100%; height:300px"></div>
4.初始化 配置值
const option = {}
var myChart =echarts.init(document.getElementById('echartContainer'));
myChart.setOption(option,true);
// setOption有三个参数 chart.setOption(option, notMerge, lazyUpdate...);
// lazyUpdate—— 可选,在设置完 option 后是否不立即更新图表,默认为 false,即立即更新。
window.onresize = ()=>{
myChart.resize();
}
5.窗口自适应
window.onresize = ()=>{
myChart.resize();
}