记录下vue 中引用echarts 出现 "TypeError: Cannot read property 'getAttribute' of undefined"问题
今天做项目,用echarts展示数据 ,自己测试 先测试 了下。写的代码html:
<div ref="myChart" style="height:300px;width:100%"></div>
JS
methods: {
drawLine() {
// 基于准备好的dom,初始化echarts实例
let myChart = this.$echarts.init(this.$refs.myChart);
// 绘制图表
myChart.setOption({
title: { text: "在Vue中使用echarts" },
tooltip: {},
xAxis: {
data: ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
},
yAxis: {},
series: [
{
name: "销量",
type: "bar",
data: [, , , , , ]
}
]
});
}
},
mounted() {
this.drawLine();
}
结果报"TypeError: Cannot read property 'getAttribute' of undefined"的错。。

百度了下,说是dom没有加载完的问题,要放在this.$nextTick改成
mounted() {
this.$nextTick(() => {
this.drawLine();
});
}
这样可以了。
后来测试 了下,用vif控制 隐藏与显示也是报这样的错。。vshow不会。
原理还是一样吧,vif是dom不加载 的。vshow只是把dom display:none,还是加载了
记录下vue 中引用echarts 出现 "TypeError: Cannot read property 'getAttribute' of undefined"问题的更多相关文章
- 在vue中使用echarts报错Cannot read property getAttribute of null
报错信息如下: 报错代码: mounted() { // ... this.drwaCharts() // drawCharts方法为自己定义的包含渲染 echarts 图表的方法 // ...} 之 ...
- [Vue warn]: Error in render: "TypeError: Cannot read property '0' of undefined、vuejs路由使用的问题Error in render function
1.[Vue warn]: Error in render: "TypeError: Cannot read property '0' of undefined 注意,只要出现Error i ...
- vue.common.js?e881:433 TypeError: Cannot read property 'nodeName' of undefined
我觉得吧,是这么个原因,就是响应式要找这个node改它的内容,没找着,就报错了. 用computed监控vuex的state属性,绑定到页面上,如果这个属性改了,因为响应式,那么就要更改页面,如果页面 ...
- vue 报错解决:TypeError: Cannot read property '_t' of undefined"
前端报错如下: [Vue warn]: Error in render: "TypeError: Cannot read property '_t' of undefined" 是 ...
- 在vue中引用echarts导致Cannot read property getAttribute of null ?
报错信息如下: 之前一直用echarts没有出现过这个问题,所以当这个问题出现时我就开始了各种查,试了几种方法依旧报错,比如: 1.在mounted() {},写成如下形式:(依旧报错) this.$ ...
- app.js:1274 [Vue warn]: Error in render: "TypeError: Cannot read property 'object_id' of undefined"问题小记
凌晨遇到一个控制台报错的信息,总是显示有对象中的元素未定义 明明是有把定义对象的值的,后面发现是把没有返回值的函数又赋值一遍给未定义的元素所属的对象,
- vue,js 使用中报错 TypeError: Cannot read property '__ob__' of undefined
原因: data中没有加return 切记!切记!
- [Vue warn]: Error in render: "TypeError: Cannot read property 'matched' of undefined" found in <App> at src/App.vue
当用Vue模块化开发时,输入 http://localhost:8080 页面没有显示,首先按F12,检查是否有如下错误 话不多说,直接看下面: 解决方法1 如果是上面出的问题,以后就要注意了哦, ...
- vue2.XX 提示[Vue warn]: Error in render: "TypeError: Cannot read property 'img' of undefined"
item 是向后台请求的一条数据,里面包含img,但是却提示img未定义 父组件向子组件传递数据时, 子组件 具体代码: <img :src="item.img" /> ...
随机推荐
- jq序 选择器
1.库和框架 库:小而精 直接操作DOM css() jquerry封装js的那些操作: 事件,属性, ajax(交互的技术),DOM,选择器 框架:大而全 事件,DOM,属性操作,ajax,&qu ...
- CSS换行知识
换行规则 CSS可以指定文字多行时换行的规则,说白了就是指定哪些地方可以换行 相关属性 word-break The word-break CSS property sets whether line ...
- impala进阶
一.impala存储 1.文件类型 2.压缩方式 二.impala分区 1.创建分区方式 partitioned by 创建表时,添加该字段指定分区列表: create table t_person( ...
- php-fpm指定配置文件及php相关配置命令
[root@hostname centos7 sbin]# ./php-fpm -c /usr/local/php/etc/php.ini -y /usr/local/php/etc/php-fpm. ...
- 第21课 shared_ptr共享型智能指针
一. shared_ptr的基本用法 (一)与unique_ptr的比较 比较 shared_ptr unique_ptr 备注 初始化 ①shared_ptr<T> sp; sp.res ...
- Spring中抽象类中使用EmbeddedValueResolverAware和@PostConstruct获取配置文件中的参数值
我的需求: 我有一个 abstract class 中包含了很多子类中需要用到的公共方法和变量,我想在抽象类中 使用@Value获取*.properties中的值.但是@Value必须要在Spring ...
- SQL --------------- between 和< >
between值 and 值 运算符用于选取介于两个值之间的数据范围内的值,常与where一块使用between运算符选择给定范围内的值.值可以是数字,文本或日期. 使用between的时候会与and ...
- Eureka的集群配置
1:步骤说明 2:修改映射配置 3:修改Eureka的.yml配置文件 以其中一个为例 4:在8001中同时注册 5:测试结果
- hbase源码之 compact源码(一)
hbase compact流程较多,这里分章节介绍,首先介绍compact在regionserver中的调用流程,并不会涉及真正的compact读取合并文件的流程,后续介绍. 在regionserve ...
- Mysql 错误 ERROR 1 (HY000) at line 1: Can't create/write to file '/home/kaizenly/cfg_dict.csv' (Errcode: 13 - Permission denied)
[1]问题描述 (1)执行SQL语句: use billing; select * from cfg_dict into outfile '/home/kaizenly/cfg_dict.csv' f ...