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>- ✓Correct answer: With the
defineProps()compiler macro, which doesn't need to be imported - 2With
import { props } from 'vue' - 3Props don't need to be declared; everything passed becomes a prop
Explanation
defineProps and defineEmits are compiled away by the SFC compiler. With TypeScript you can declare props by type: defineProps<{ title: string }>().