Subscribe on changes!

In a template defintion, $refs is not properly updated if no explicit ref is used to reference the element in the component setup

avatar
Nov 30th 2021

Version

3.2.23

Reproduction link

sfc.vuejs.org/

Steps to reproduce

Open the SFC example.

What is expected?

The tagName of the paragraph should be displayed.

What is actually happening?

It is not displayed.

But when you replace 'false' by 'true', then it is shown, in both cases. Thus, if an explicit ref is used in the component setup then $refs are properly updated in the template definition.


I want to pass references to elements to other components, in order to easily display their bounding boxes.

avatar
Nov 30th 2021

Just use refTop directly when using the setup syntax

avatar
Nov 30th 2021

Sorry but here's another example.

As you can see, the tagName only appears when the component is updated. This seems like a weird behaviour, and people should be at least warned about this in the docs.

avatar
Dec 1st 2021

@rgaudy You just need to define refTop and use refTop directly: example