Last active
June 18, 2020 01:23
-
-
Save KenoLeon/217d2654d10efa2f9eb56e2869482c0c to your computer and use it in GitHub Desktop.
Cascading vue props
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"> | |
| <bootsCard v-bind="{ cardT : cardTitle, alertD:alertData }"/> | |
| </div> | |
| </template> | |
| <script> | |
| import bootsCard from './components/bootsCard.vue' | |
| export default { | |
| name: 'App', | |
| components: { | |
| bootsCard | |
| }, | |
| data() { | |
| return { | |
| cardTitle: 'Very Important Title', | |
| alertData: 'Danger Will Robinson' | |
| } | |
| } | |
| } | |
| </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/bootsCard.vue --> | |
| <template> | |
| <div class="card" style="margin:auto;width:600px;"> | |
| <div class="card-header"> | |
| {{cardT}} | |
| </div> | |
| <bootsAlert v-bind="{ alertD }"/> | |
| </div> | |
| </template> | |
| <script> | |
| import bootsAlert from './bootsAlert.vue' | |
| export default { | |
| props: ['cardT', 'alertD'], | |
| name: 'bootsCard', | |
| components: { | |
| 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/bootAlert.vue --> | |
| <template> | |
| <div> | |
| <br> | |
| <div class="alert alert-danger" role="alert" style="margin:auto;width:400px;"> | |
| {{alertD}} | |
| </div> | |
| <br> | |
| </div> | |
| </template> | |
| <script> | |
| export default { | |
| props: ['alertD'], | |
| name: 'bootsAlert' | |
| } | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment