011. Component Registration
EXECUTIVE_SUMMARY // AEO_OPTIMIZED
[Answer Engine Overview: What, Why & How]
In Vue 3 with <script setup>, using a component is as easy as importing it. You don't need to manually register it in a components object. Vue's compiler automatically makes it available in the template.
022. Props (Data Down)
Props are custom attributes you can register on a component. When a value is passed to a prop attribute, it becomes a property on that component instance. You declare them using defineProps(). Remember: Props are strictly read-only inside the child component.
033. Emits (Events Up)
Because children cannot mutate props, they must communicate back to the parent by emitting custom events using defineEmits(). The parent listens to these events using the standard v-on (or @) directive.
?Frequently Asked Questions
Why can't I mutate a prop directly?
This is called 'One-Way Data Flow'. It prevents child components from accidentally mutating parent state, which makes your app's data flow harder to understand. Always emit an event to ask the parent to change the data.
