Created
June 17, 2020 02:02
-
-
Save KenoLeon/c7330309d0dbeb56ed0524e999296657 to your computer and use it in GitHub Desktop.
Parent and multiple child props in Vue
This file contains hidden or 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
| <!-- FILE: App.vue --> | |
| <!-- NOTE: Import bootstrap on main.js --> | |
| <template> | |
| <div id="app"> | |
| <bootsAlert v-bind="{ alertD: alertData }"/> | |
| <bootsList v-bind="{ listD : listData }"/> | |
| </div> | |
| </template> | |
| <script> | |
| import bootsAlert from './components/bootsAlert.vue' | |
| import bootsList from './components/bootsList.vue' | |
| export default { | |
| name: 'App', | |
| components: { | |
| bootsAlert, | |
| bootsList | |
| }, | |
| data() { | |
| return { | |
| alertData: 'This was a triumph', | |
| listData: [ | |
| { item: 'Eeny' }, | |
| { item: 'Meeny' }, | |
| { item: 'Miny' }, | |
| { item: 'Moe' } | |
| ] | |
| } | |
| } | |
| } | |
| </script> | |
| <style> | |
| #app { | |
| font-family: Avenir, Helvetica, Arial, sans-serif; | |
| -webkit-font-smoothing: antialiased; | |
| -moz-osx-font-smoothing: grayscale; | |
| text-align: center; | |
| color: #2c3e50; | |
| margin-top: 60px; | |
| } | |
| </style> |
This file contains hidden or 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
| <!-- FILE: components/bootsAlert.vue --> | |
| <template> | |
| <div> | |
| <div class="alert alert-success" role="alert" style="margin:auto;width:600px;"> | |
| {{alertD}} | |
| </div> | |
| <br> | |
| </div> | |
| </template> | |
| <script> | |
| export default { | |
| props: ['alertD'], | |
| name: 'bootsAlert' | |
| } | |
| </script> |
This file contains hidden or 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
| <!-- FILE: components/bootsList.vue --> | |
| <template> | |
| <div> | |
| <ul class="list-group" style="margin:auto;width:600px;"> | |
| <li v-for="element in listD" :key="element" class="list-group-item"> | |
| {{ element.item }} | |
| </li> | |
| </ul> | |
| </div> | |
| </template> | |
| <script> | |
| export default { | |
| props: ['listD'], | |
| name: 'bootsList' | |
| } | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment