How does vue get the position of the current element relative to the parent element?

because it is circular, so $refs should not be used, right?
didn"t you see any merit when you put the this console out?

Jun.06,2021

actually this has nothing to do with vue. You get the current dom node through ref, and then obtain attributes such as offsettop through the native js method.


the elements generated by the loop can also be obtained using ref , but it depends on whether the circular data is customized locally or returned from the server. In a word, if you ensure that the node has been rendered, You can get it by using nextTick .
as to how to ensure rendering, generally speaking, there are mounted periods and updated periods when dynamically changing data


The

native JS also has no way to directly take the "position relative to the parent element". If you want to be accurate, you still have to take the position of the two nodes and do subtraction.

The

loop can use $refs , and the $refs after the loop is an array, so you can use it as much as you want. It is important to note, however, that because browsers cache DOM operations, you have to wait until the next time period to get the true location and size of the node. This applies to $nextTick

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-1b3bdd7-34695.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-1b3bdd7-34695.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?