Vue · Junior · Question 28 of 75

How does a child component declare the props it accepts in <script setup>?

<script setup>
const props = defineProps({ title: String, likes: Number });
</script>

Explanation

defineProps and defineEmits are compiled away by the SFC compiler. With TypeScript you can declare props by type: defineProps<{ title: string }>().

Further reading

Problem with a question

Vue · Junior · question 28

Test yourself

Take the Vue · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz