Skip to content

Instantly share code, notes, and snippets.

@djirdehh
Last active April 21, 2022 18:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djirdehh/5b85432e2050dc44051e6f901de75d4e to your computer and use it in GitHub Desktop.
Save djirdehh/5b85432e2050dc44051e6f901de75d4e to your computer and use it in GitHub Desktop.
Example of passing props in Vue
<!-- 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