Vue Error in callback for immediate watcher “height”: “TypeError: Cannot read property ‘style’ of

Vue error 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

As follows:

The error is because tabledata is an empty array this.monthTradingTableHeight This is empty

solve:

1. Do not render when there is no data, and add a style with no data

code:

effect:

2. Or HTML code unchanged, modify JS, and give it when there is no data this.monthTradingTableHeight If you assign a value or ‘auto’, you will not report an error

code:

this.monthTradingTableHeight = tableData.length > 9 ? '310' : 'auto'

effect:

Here I choose the first solution, which is to add a style with no data.

Read More: