TypeError: Cannot read properties of undefined (reading ‘queryComponents‘)

错误复现

在vue项目开发中,使用Echarts报错:Cannot read properties of undefined (reading 'queryComponents'),无法读取未定义的属性(读取"queryComponents")

解决方案

  • 定位问题是手动绑定事件的时候,异步执行时机的问题
  • this.$nextTick 偶现执行超前于 chart.setOptions()
  • 改为 setTimeout 因为 setTimeout 方法在 this.$nextTick 之后执行

如果以上无效的话,那就是加载顺序的问题啦,所以要在这个方法执行前就setOption一次,这个问题就解决了。

相关推荐
子兮曰21 小时前
OpenClaw入门:从零开始搭建你的私有化AI助手
前端·架构·github
吴仰晖21 小时前
使用github copliot chat的源码学习之Chromium Compositor
前端
1024小神21 小时前
github发布pages的几种状态记录
前端
不像程序员的程序媛1 天前
Nginx日志切分
服务器·前端·nginx
Daniel李华1 天前
echarts使用案例
android·javascript·echarts
北原_春希1 天前
如何在Vue3项目中引入并使用Echarts图表
前端·javascript·echarts
JY-HPS1 天前
echarts天气折线图
javascript·vue.js·echarts
尽意啊1 天前
echarts树图动态添加子节点
前端·javascript·echarts
吃面必吃蒜1 天前
echarts 极坐标柱状图 如何定义柱子颜色
前端·javascript·echarts
O_oStayPositive1 天前
Vue3使用ECharts
前端·javascript·echarts