0 day streak
javascript / beginner
Snippet

Defining Props

Props are custom attributes you can register on a component. When a value is passed to a prop attribute, it becomes a property on that component instance.

snippet.js
javascript
1
2
3
4
const props = defineProps({
username: String,
age: Number
});
vue
Breakdown
1
defineProps({ ... });
A compiler macro used to declare the props that a component accepts.
2
username: String
Defines a prop named 'username' and specifies that its value should be a text string.