Data To Component

Calling Component w Vars

2025-01-08

Define Prop in Child Component

<!-- ChildComponent.vue -->
<script setup>
const props = defineProps(['myVar'])
</script>

<template>
  <div>{{ props.myVar }}</div>
</template>

Pass Var to Child Component

<!-- ParentComponent.vue -->
<script setup>
const myVar = ref('Hello from parent')
</script>

<template>
  <ChildComponent :myVar="myVar" />
</template>

 

Copyright @ 2024 Anne Brown