0
0
Vueframework~5 mins

Defining components in Vue - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a component in Vue?
A component in Vue is a reusable piece of the user interface. It can have its own structure, style, and behavior, like a small building block for your app.
Click to reveal answer
beginner
How do you define a component using the Composition API in Vue 3?
You define a component using <script setup> with the Composition API. This lets you write reactive code simply and clearly inside a single file component.
Click to reveal answer
intermediate
What is the purpose of the name property in a Vue component?
The name property gives your component a name. This helps with debugging and allows recursive components to call themselves by name.
Click to reveal answer
intermediate
How do you register a component locally in Vue?
You import the component and add it to the <code>components</code> option inside your component's options object. This makes it usable only inside that component.
Click to reveal answer
advanced
What is the difference between a functional component and a stateful component in Vue?
A functional component is a simple component without reactive state or lifecycle hooks. It just receives props and returns UI. A stateful component can have reactive data and lifecycle hooks.
Click to reveal answer
Which tag is used to define a Vue component with the Composition API?
A<template>
B<component>
C<script setup>
D<script>