ECharts——运行错误[TypeError: Cannot read property ‘type‘ of undefined]解决方案

Posted Starzkg

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ECharts——运行错误[TypeError: Cannot read property ‘type‘ of undefined]解决方案相关的知识,希望对你有一定的参考价值。

issues

https://github.com/apache/echarts/issues/13943

问题描述

Uncaught TypeError: Cannot read property 'type' of undefined
    at Object.reset (dataSample.js?fdde:104)
    at Task.seriesTaskReset [as _reset] (Scheduler.js?69ff:478)
    at reset (task.js?f47d:232)
    at Task.taskProto.perform (task.js?f47d:129)
    at eval (Scheduler.js?69ff:294)
    at HashMap.each (util.js?1ee1:669)
    at eval (Scheduler.js?69ff:278)
    at Array.forEach (<anonymous>)
    at each (util.js?1ee1:300)
    at performStageTasks (Scheduler.js?69ff:247)

问题分析

框架对属性的代理对象,会影响到ECharts实例底层的运行

解决方案

方法一

不使用响应式API

方法二

使用 shallowRef 替代ref

const chart = ref<ECharts>();

改成

const chart = shallowRef();

参考文章

  • https://v3.cn.vuejs.org/api/refs-api.html#shallowref

以上是关于ECharts——运行错误[TypeError: Cannot read property ‘type‘ of undefined]解决方案的主要内容,如果未能解决你的问题,请参考以下文章

java中echarts关系图中如何引用dataTool:Uncaught TypeError: Cannot read property 'gexf' of undefined

在vue中使用echarts报错"TypeError: Cannot read property 'getAttribute' of null

Echarts 明明和官方文档配置一致,图表加载却是报错:Error in mounted hook: "TypeError: Cannot read property 'get&#

vue中使用echarts遇到的Error in v-on handler: "TypeError: Cannot read property 'getAttribute'

Uncaught TypeError: wave.ensureState is not a function

Uncaught TypeError: wave.ensureState is not a function