Skip to content

Instantly share code, notes, and snippets.

@KenoLeon
Last active June 18, 2020 01:23
Show Gist options
  • Select an option

  • Save KenoLeon/217d2654d10efa2f9eb56e2869482c0c to your computer and use it in GitHub Desktop.

Select an option

Save KenoLeon/217d2654d10efa2f9eb56e2869482c0c to your computer and use it in GitHub Desktop.
Cascading vue props
<!-- 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>
<!-- 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>
<!-- 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