1.安裝echarts
npm install echarts --save
2.可以在項目入口一如全局 也可以在局部頁面引入
1.在單獨頁面引入
import echarts from 'echarts'
2. 也可以在main.js 引入全局
import echarts from 'echarts' //放入全局vue 對象中 Vue.prototype.$echarts = echarts
3.div容器
<div id="main" style="width: 600px;height: 400px;"></div> var demo = echarts.init(document.getElementById("main")); demo.setOption({ ...渲染圖表js });
4.圖表重新渲染的方法 需要自適應寬度 放到窗口變化事件中OK
echarts.resize();