BeforeDestroy cannot get the height of the ref scroll bar

beforeDestroy(){
        console.log("scrollTop-",this.$refs.main.scroller.scrollTop)
 
      },
  

clipboard.png

the scroll bar height of ref cannot be obtained in the beforeDestroy cycle. In created, I can use a timer to get it. To find a solution, or to monitor the scroll bar height of ref, ask everyone who has encountered it to solve

.
Apr.20,2022

in beforeDestroy , although the instance still exists, the height of the container is already 0, so the value of the scroll bar is also 0

.

timer is not recommended. You can get the height in mounted , when the dom has been loaded. If you have an asynchronous data request, you should write the acquisition height in the hook after getting the data

.

bind the listening event of the scroll bar in mounted and record the height value of the scroll bar on the instance

  beforeDestroy () {
    console.log(this.scrollTopRecord)
    this.$refs.main.scroller.removeEventListener('scroll', this.recordScroll)
  }
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e597ef-5a584.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e597ef-5a584.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?