templateRef

Commons
stable

Create a dual-purpose template ref that can be passed as a Vue callback ref and also read like a normal ShallowRef. Exposes both `.value` (the raw ComponentPublicInstance or HTMLElement) and `.el` (the resolved HTMLElement).

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Return value

The value returned by this util.

A function that can be used directly as a `:ref` binding, with `.value` (raw ref target) and `.el` (resolved HTMLElement) properties attached.

Usage

Examples

Ready-to-paste usage snippets.

Attach a template ref and read its element

typescript