0Pricing
Vue Academy · Lesson

defineExpose and useAttrs

Exposing component internals with defineExpose(), useAttrs() for fallthrough attributes.

Exposing and Forwarding

Two more tools round out component communication: defineExpose lets a parent reach into a child, and useAttrs gives you the leftover attributes the parent passed. Both are common in reusable components.

Components Are Closed by Default

With <script setup>, nothing inside the component is accessible from a parent template ref. This encapsulation is good, but sometimes a parent legitimately needs to call a child method.

All lessons in this course

  1. Introduction to script setup
  2. defineProps and defineEmits
  3. defineExpose and useAttrs
  4. Importing and Using Composables in script setup
← Back to Vue Academy