s9e125 switching multiple components with dynamic components

This commit is contained in:
Tyrel Souza 2018-04-17 23:22:32 -04:00
parent 83ba9f9a29
commit 24a5ed444e
No known key found for this signature in database
GPG Key ID: 5A9394D4C30AEAC0

View File

@ -2,10 +2,18 @@
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-xs-12"> <div class="col-xs-12">
<app-quote> <button @click="selectedComponent = 'appQuote'">Quote</button>
<button @click="selectedComponent = 'appAuthor'">Author</button>
<button @click="selectedComponent = 'appNew'">New</button>
<hr>
<!--<app-quote>-->
<!--</app-quote>-->
<component :is="selectedComponent"
>
<h2 slot="title">{{quoteTitle}}</h2> <h2 slot="title">{{quoteTitle}}</h2>
<p>A Simple Quote</p> <p>A Simple Quote</p>
</app-quote> </component>
</div> </div>
</div> </div>
</div> </div>
@ -13,15 +21,20 @@
<script> <script>
import Quote from './components/Quote.vue' import Quote from './components/Quote.vue'
import Author from './components/Author.vue'
import New from './components/New.vue'
export default { export default {
data(){ data(){
return { return {
quoteTitle: "The Quote" quoteTitle: "The Quote",
selectedComponent: 'appQuote'
} }
}, },
components: { components: {
appQuote: Quote appQuote: Quote,
appAuthor: Author,
appNew: New,
} }
} }