javascript / beginner
Snippet
Component Props: defineProps
Props are custom attributes used to pass data from a parent component down to a child component. They make components reusable and dynamic.
snippet.js
1
2
3
4
5
6
<script setup>const props = defineProps({title: String,views: Number});</script>
vue
Breakdown
1
const props = defineProps({ ... });
Uses the compiler macro to define the expected inputs for the component.
2
title: String
Specifies that the 'title' prop must be a text string.