TypeError: Cannot read property 'scrollTo' of null
2019-04-16 10:53
656 查看
在使用react中的’IScroll‘方法时可能会出现“TypeError: Cannot read property 'scrollTo' of null”报错,原因是DOM树还未建立完成或者被卸载了,这时只需要在使用’IScroll‘方法时加一个判断:
[code]this.myScroll && this.myScroll.scrollTo(0, 50, 1000, IScroll.utils.ease.quadratic);
其他’IScroll‘方法同理。
相关文章推荐
- JavaScript:Uncaught TypeError Cannot read property 'id' of null。
- Uncaught TypeError: Cannot read property 'getItem' of null
- TypeError: Cannot read property 'split' of null
- EasyUI datagrid报错:Uncaught TypeError: Cannot read property 'width' of null
- Uncaught TypeError: Cannot read property 'length' of null
- discuz 出现了Uncaught TypeError: Cannot read property 'appendChild' of null
- Uncaught TypeError: Cannot read property 'value' of null
- Uncaught TypeError: Cannot read property 'querySelector' of null
- 关于js Uncaught TypeError: Cannot read property 'style' of null 问题
- Uncaught TypeError: Cannot read property 'prototype' of null using Openerp 7.0
- cocos2d-js-----Uncaught TypeError: Cannot read property 'style' of null
- canvas出现Uncaught TypeError: Cannot read property 'getContext' of null 错误
- Uncaught TypeError: Cannot read property 'width' of null
- js事件处理程序 Uncaught TypeError: Cannot read property 'addEventListener' of null
- Uncaught TypeError: Cannot read property of 'name' null
- Uncaught TypeError: Cannot read property 'value' of null
- 关于"Uncaught TypeError: Cannot read property 'time' of null"的处理
- Uncaught TypeError: Cannot read property 'hasOwnProperty' of null
- Uncaught TypeError: Cannot read property 'offsetTop' of null
- js提示Uncaught TypeError: Cannot read property 'options' of null