报错内容
Cannot read properties of undefined (reading ‘type’) 或 **.resize is not a function
Cannot read properties of undefined (reading 'type')
**.resize is not a function
解决方案
第一步:
不要使用 ref 或 reactive 包装 echarts 实例。 使用公共变量或 shallowRef 以避免对 echarts 实例进行深度监视。
import { shallowRef } from 'vue'
let chartInstance = shallowRef(null)
第二步:
在vue3使用proxy监听的,Echarts无法从中获取内部变量
onMounted(()=>{
const charEle = document.getElementById(chartId);
myChart.value = echarts.init(chartDom);
window.addEventListener('resize', () => {
if(myChart.value){
myChart.value.resize()
}
})
})