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

2023-05-16

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
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

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

随机推荐