Skip to main content

$refs

The $refs special helper allows access to registered reference elements within a component. This is useful for interacting directly with elements assigned a d-ref identifier.

Syntax

<p d-ref="text">Hello!</p>

Inside the component:

console.log($refs.text.textContent); // "Hello!"

Example

<div>
<input d-ref="inputBox" type="text" placeholder="Type here..." />
<button @click="$refs.inputBox.focus()">Focus Input</button>
</div>