Echarts在resize时报错
报错: Uncaught TypeError: Cannot read properties of undefined (reading ‘type’)
报错: Uncaught TypeError: Cannot read getAxis undefined (reading ‘type’)
因: Echarts 管理的状态和数据与 Vue 的响应式产生冲突,导致Echarts 无法正常更新而报错。
解决:取消 VUE 的响应式系统观测 Echarts 的变化更新,让Echarts 自动更新。
markRaw 将 Echarts 实例标记为原始对象
// 导入 markRaw
import { markRaw } from 'vue';
const chartInstance: any = ref(null);
// 标记这个DOM对象, Vue 不要将其转换为响应式数据。
chartInstance.value = markRaw(echarts.init( document.getElementById('chartline'))) ;
————————————————