[Vue warn]: Error in mount hook: “TypeError: Cannot read properties of null (reading ‘getAttribute‘)

简介: [Vue warn]: Error in mount hook: “TypeError: Cannot read properties of null (reading ‘getAttribute‘)

一、在运行Vue项目时出现了上述错误

出现该错误的原因是Echarts的图形容器还未生成就对其进行了初始化,

利用Vue中的ref和$refs 来代替document.getElementById()获取该图形容器对象

1.一、在运行Vue项目时出现了上述错误
出现该错误的原因是Echarts的图形容器还未生成就对其进行了初始化,
利用Vue中的ref和$refs 来代替document.getElementById()获取该图形容器对象

二、想在el-dialog对话框中展示Echarts图表时,出现了如上错误

通过$refs获取不到 el-dialog对话框中的子组件对象,返回的都是undefined,这也就导致了上图的错误。


解决办法:


在通过this.$refs  获取el-dialog对话框中的子组件对象之前加入以下函数即可:


this.$nextTick(function () {           });


在dialog框生成后再去初始化echarts


相关文章
|
27天前
|
JavaScript
报错[Vue warn]: $listeners is readonly. $attrs is readonly.怎么解决?
报错[Vue warn]: $listeners is readonly. $attrs is readonly.怎么解决?
|
5月前
|
JavaScript
鬼火起~为什么报错[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the
鬼火起~为什么报错[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the
|
4月前
|
JavaScript 小程序 前端开发
[Vue warn]: Error in callback for watcher “fileList“: “TypeError: Cannot create property ‘uid‘ on st
[Vue warn]: Error in callback for watcher “fileList“: “TypeError: Cannot create property ‘uid‘ on st
|
4月前
|
Java
Error:(15, 13) java: No property named “id” exists in source parameter(s). Did you mean “null”?
Error:(15, 13) java: No property named “id” exists in source parameter(s). Did you mean “null”?
32 1
|
4月前
|
JavaScript 前端开发
[Vue Router warn]: Component “default“ in record with path “/xx“ is a function that does not return
[Vue Router warn]: Component “default“ in record with path “/xx“ is a function that does not return
171 0
|
4月前
|
JavaScript
解决使用elementUI的el-date-picker报[Vue warn]: Avoid mutating a prop ...Prop being mutated: “placement“的问题
解决使用elementUI的el-date-picker报[Vue warn]: Avoid mutating a prop ...Prop being mutated: “placement“的问题
44 0
|
5月前
|
JavaScript
[Vue warn]: Unhandled error during execution of scheduler flush. This is likely a Vue internals bug.
[Vue warn]: Unhandled error during execution of scheduler flush. This is likely a Vue internals bug.
118 0
|
5月前
|
编解码 JavaScript 编译器
【Vue warn】If this is a native custom element, make sure to exclude it from component resolution ……
【Vue warn】If this is a native custom element, make sure to exclude it from component resolution ……
|
5月前
|
JavaScript
[Vue warn]: Unknown custom element: <Top> - did you register the component correctly?
[Vue warn]: Unknown custom element: <Top> - did you register the component correctly?
|
6月前
|
编译器
error TS2322 Type ‘string null‘ is not assignable to type ‘string undefined‘.
error TS2322 Type ‘string null‘ is not assignable to type ‘string undefined‘.
96 1