Last active
April 21, 2022 18:05
-
-
Save djirdehh/5b85432e2050dc44051e6f901de75d4e to your computer and use it in GitHub Desktop.
Example of passing props in Vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Parent Component --> | |
<template> | |
<div> | |
<ChildComponent :numbers="numbers" /> | |
</div> | |
</template> | |
<script> | |
import ChildComponent from './child-component.js'; | |
export default { | |
name: 'ParentComponent', | |
data() { | |
return { | |
numbers: [1, 2, 3] | |
} | |
}, | |
components: { | |
ChildComponent | |
} | |
} | |
</script> | |
<!-- Child Component --> | |
<template> | |
<div> | |
<h2>The numbers are {{ numbers }}!</h2> | |
</div> | |
</template> | |
<script> | |
export default { | |
name: 'ChildComponent', | |
props: { | |
numbers: Array | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment