【bug】immediate watcher “height“ “TypeError Cannot read properties of undefined (reading ‘style‘)“

The error is as follows:
Because the page uses window dynamic rendering

mounted() {
      this.windowRender()
    },
 /** Window dynamic rendering */
        windowRender() {
        this.screenWidth = document.body.clientWidth
        this.screenHeight = document.body.clientHeight
        window.onresize = () => {
          this.screenWidth = document.body.clientWidth
          this.screenHeight = document.body.clientHeight
        }
      },

When giving the height of the list, it is given like this

<el-table
              :data="tableData"
              border
              class="elTable"
              :height="screenHeight-170"
              >

Then I have a lot of page lists. There is one I wrote directly like this: height=”screenHeight”, I can’t write it like this, maybe because I can’t get the value when I monitor the height, replace it with: height=”screenHeight – 0″ or :height=”screenHeight +’px'” will not report an error

Leave a Comment

Your email address will not be published. Required fields are marked *