Jul 14, 2024
ref
and typed with a UserType
imported at the top of the script tag.App.vue
has a UserCard
component with basic Vue file structure.UserCard
component.UserCard
:
<UserCard :user="user" />
UserCard
component:
const props = defineProps({
user: UserType
});
<div>{{ user.firstName }}</div>
const props = defineProps({
id: UserType['id'],
firstName: UserType['firstName'],
lastName: UserType['lastName'],
email: UserType['email']
});
user
prop.user
prop.v-bind
to bind entire object:
<UserCard v-bind="user" />
v-bind
destructures object properties and binds them to designated props within the component.Web Dev Daily
.learn N.D
.