TypeError: Cannot read property 'getAttribute' of undefined
程序员文章站
2022-06-07 13:17:28
...
今天使用echarts + vue 做 图标,运行时提示vue.runtime.esm.js?2b0e:619 [Vue warn]: Error in mounted hook: "TypeError: Cannot read property 'getAttribute' of undefined"
’
网上找了些朋友说是,什么要将加载放到mounted的this.$nextTick
中,其实不然,是我吧refs 的值写错了
现在我们就来开始找错…
html
<template>
<div class="echart-box" style="width: 280px;
height:220px" ref="line_only_dom"></div>
</template>
js
mounted() {
this.drawLine();
},
methods: {
drawLine() {
let self = this;
let line_dom = this.$refs.line_dom;
this.mychart = this.$echarts.init(line_dom);
}
}
找到错误了吧
只要吧 let line_dom = this.$refs.line_dom;
改为 let line_only_dom = this.$refs.line_only_dom;
问题即可解决
上一篇: 【Java基础】JDK1.8新特性
推荐阅读
-
Vue报错:Uncaught TypeError: Cannot assign to read only property’exports‘ of object
-
npm ERR! Cannot read property 'path' of null
-
js报错 Cannot read property 'getAttribute' of null
-
[VUE ERROR] Error in render: "TypeError: Cannot create property 'header' on boolean 'true'"
-
微信小程序报Cannot read property 'setData' of undefined的错误
-
webpack报错Cannot read property 'presetToOptions' of undefined
-
Extjs4---Uncaught TypeError: Cannot read property ‘items’ of undefined
-
JavaScript Uncaught TypeError: Cannot read property 'value' of null
-
Cannot read property 'tap' of undefined
-
Vue报错:Uncaught TypeError: Cannot assign to read only property’exports‘ of object’#