TypeError: Cannot read property 'scrollTo' of null
程序员文章站
2022-03-04 11:10:32
...
在使用react中的’IScroll‘方法时可能会出现“TypeError: Cannot read property 'scrollTo' of null”报错,原因是DOM树还未建立完成或者被卸载了,这时只需要在使用’IScroll‘方法时加一个判断:
this.myScroll && this.myScroll.scrollTo(0, 50, 1000, IScroll.utils.ease.quadratic);
其他’IScroll‘方法同理。
推荐阅读
-
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’#