Uncaught TypeError: Cannot read properties of undefined (reading 'type')

668 阅读1分钟

Snipaste_2024-11-06_13-49-08.png

解决方案:在Echarts中,初始化的实例一般也不用去更改,更多的是去调用其自带的方法,所以不建议用ref

  1. 使用浅层响应式shallowRef进行存储Echarts实例

const chartInstance = shallowRef<echarts.ECharts | null>(null)

2.使用markRaw

const chartInstance = markRaw<echarts.ECharts | null>(null)

3.定义常量存储echarts,不使用ref

github.com/apache/echa…