Recall & Review
beginner
What is the purpose of the
<script setup> syntax in Vue 3?It is a simpler and more concise way to write the component's script logic using the Composition API without the need to explicitly return values or define a
setup() function.Click to reveal answer
beginner
How do you declare reactive state variables inside
<script setup>?You use the
ref() or reactive() functions imported from Vue to create reactive state variables directly inside the <script setup> block.Click to reveal answer
intermediate
Can you use
props directly inside <script setup> without defining them explicitly?No, you must define props using the
defineProps() helper function to declare the expected props and their types inside <script setup>.Click to reveal answer
intermediate
How do you emit events from a component using
<script setup>?You use the
defineEmits() helper function to declare the events your component can emit, then call the returned emit function to send events.Click to reveal answer
beginner
What is one advantage of using
<script setup> over the traditional setup() function?It reduces boilerplate code by removing the need to return variables and functions explicitly, making the component code cleaner and easier to read.
Click to reveal answer
Which function is used to declare props inside
<script setup>?✗ Incorrect
The
defineProps() function is the official way to declare props in <script setup>.How do you create a reactive variable inside
<script setup>?✗ Incorrect
Vue provides
ref() and reactive() to create reactive variables.What must you do to emit an event from a component using
<script setup>?✗ Incorrect
You declare events with
defineEmits() and then call the returned emit function.Which of these is NOT a benefit of
<script setup>?✗ Incorrect
Vue 3 Composition API and
<script setup> do not support class-based components.Where do you write the
<script setup> block in a Vue component?✗ Incorrect
You write
<script setup> as a <script> tag with the setup attribute.Explain how to define props and emit events using
<script setup> in Vue 3.Think about how you tell Vue what props and events your component uses.
You got /3 concepts.
Describe the main advantages of using
<script setup> compared to the traditional setup function.Focus on how it makes writing components easier and cleaner.
You got /4 concepts.