最近在做Echarts项目的时候,在组件引用的时候出现了一点小问题

VUE3+Echarts报错Cannot read property ‘type‘ of undefined_数据读取

左下角的组件应用之后,控制台报错且连带着右侧两个能正常运行的组件失效了。

VUE3+Echarts报错Cannot read property ‘type‘ of undefined_数据读取_02

查阅资料,发现可能是“商家销售统计”的组件在数据读取是响应式的原因,在响应代码中加上

1


import { markRaw } from '@vue/reactivity';


在图表初始化的引用中加上markRaw()

1

2

3

4

5


initChart() {

this.chartInstance = markRaw(echarts.init(this.$refs.rank_ref, this.theme))

//对图表初始化配置进行控制

const initOption = {

},