Next.js starter your AI actually understands. Ship internal tools in days not weeks. Pre-order $199 $499 → [Get it now]

How to expose methods in Vue 3 with defineExpose

In Vue 3 <script setup>, all bindings are private by default — parent components cannot access child component methods or data using template refs unless you explicitly expose them with defineExpose. As the creator of CoreUI with Vue development experience since 2014, I use defineExpose in CoreUI Vue components that need to provide imperative APIs, such as dialog open() and close() methods or form reset() and validate() methods. Without defineExpose, a parent’s childRef.value.open() call fails silently because the method is not exposed. This is intentional — <script setup> components are encapsulated by default, and defineExpose is an explicit contract of the public API.

Read More…
Subscribe to our newsletter
Get early information about new products, product updates and blog posts.
Dealing with Sass Deprecation Warnings in Angular 19
Dealing with Sass Deprecation Warnings in Angular 19

How to conditionally add attributes to React components
How to conditionally add attributes to React components

How to Conditionally Add a Property to an Object in JavaScript
How to Conditionally Add a Property to an Object in JavaScript

What is globalThis in JavaScript?
What is globalThis in JavaScript?

Answers by CoreUI Core Team