npm install echarts --save
引入
import * as echarts from 'echarts'
使用
<div id='chartbox'>
<div
:id="chart"
style="width:100%;height:450px"
/>
</div>
let myChart
let option = ref({})
let chart = ref("eChart" + Date.now() + Math.random()),
const resizeObserver = new ResizeObserver(entries => {
for (let entry of entries) {
if(entry.contentBoxSize) {
myChart.resize()
}
}
});
const echartinit = () => {
myChart = echarts.init(document.getElementById(chart.value))
resizeObserver.observe(document.getElementById('chartbox'));
}
const echartupdate = async () => {
await axios().then(res=>{
option.value=...
})
myChart.clear();
myChart.setOption(option.value)
}