vue报错 Error in callback for immediate watcher "height": "TypeError: Cannot read property 'style' of
vue报错vue.esm.js?eaf6:628 [Vue warn]: Error in callback for immediate watcher "height": "TypeError: Cannot read property 'style' of undefined"TypeError: Cannot read property 'style' of undefined如下:...
·
vue报错vue.esm.js?eaf6:628 [Vue warn]: Error in callback for immediate watcher "height": "TypeError: Cannot read property 'style' of undefined"
TypeError: Cannot read property 'style' of undefined
如下:
报错原因是tableData为空数组,所以this.monthTradingTableHeight 这时为空
解决:
1.判断没有数据时不渲染,添加一个暂无数据的样式
代码:
效果:
2.或html代码不变,修改js,没有数据时也给this.monthTradingTableHeight赋个值或给'auto',就不会报错了
代码:
this.monthTradingTableHeight = tableData.length > 9 ? '310' : 'auto'
效果:
这里我选择的是第一种解决方法,整体添加一个暂无数据的样式。
更多推荐
所有评论(0)