Vue add a component on button click












1















I have three templates. AddCard.vue , ImageCard.vue and VideoCard.vue



AddCard.vue has two buttons on it one is to add the Image Card and Other To Add the video Card.. I need to add components based on the button click. Here are three templates and my index.html file.



index.html



   <!doctype html>
<html lang="en">
<head>

</head>
<body>
<div id="app">
<div class="container">
<div id="dynamic_components">
<!-- add components here -->
</div>
<addcard></addcard>
</div>
</div>
<script src="{{ asset('js/app.js') }}"></script>
</body>
</html>


AddCard.vue



<template>
<div class="buttons">
ul class="no-margin-list">
<li @click="imagecard">
<span class="card_icon">
<img :src="'img/image.jpg'" >
</span>
<p>Add Image Card</p>
</a>
</li>

<li @click="videocard">
<span class="card_icon">
<img :src="'img/video.jpg'" >
</span>
<p>Add Video Card</p>
</a>
</li>
</div>
</template>
<script>
export default {
computed: {

},
methods: {
imagecard(val) {
//how to add image card
},
videocard() {
//how to add video card
}
},

}
</script>


ImageCard.vue



<template>
<h1> I am a image Card </h1>
</template>
<script>

</script>


VideoCard.vue



<template>
<h1> I am a Video Card </h1>
</template>
<script>

</script>


I need to add components dynamically one after another in the <div id="dynamic_components"> . User can add as many as cards they want.



How do I add the components dynamically. Please point me to a tutorial.










share|improve this question


















  • 1





    Keep data-driven in mind. for your cases, define one array as data/computed property=cards like [{'card-content':{}, 'card-type':'image'}, {'card-content':{}, 'card-type':'image'}], then in your template, <div> <!-- add components here --><template v-for="(card, index) in cards" :key="index" :is="card['card-type']"></template> </div>

    – Sphinx
    Jun 1 '18 at 21:02













  • @Sphinx , so each time the user clicks the button , I need to push the new array element in the computed property and v-for will take care of rendering it on the UI.

    – Stacy Thompson
    Jun 1 '18 at 21:10











  • @Sphinx Please write an answer, you just provided a great answer but as a comment...

    – Bernardo Duarte
    Jun 1 '18 at 21:13
















1















I have three templates. AddCard.vue , ImageCard.vue and VideoCard.vue



AddCard.vue has two buttons on it one is to add the Image Card and Other To Add the video Card.. I need to add components based on the button click. Here are three templates and my index.html file.



index.html



   <!doctype html>
<html lang="en">
<head>

</head>
<body>
<div id="app">
<div class="container">
<div id="dynamic_components">
<!-- add components here -->
</div>
<addcard></addcard>
</div>
</div>
<script src="{{ asset('js/app.js') }}"></script>
</body>
</html>


AddCard.vue



<template>
<div class="buttons">
ul class="no-margin-list">
<li @click="imagecard">
<span class="card_icon">
<img :src="'img/image.jpg'" >
</span>
<p>Add Image Card</p>
</a>
</li>

<li @click="videocard">
<span class="card_icon">
<img :src="'img/video.jpg'" >
</span>
<p>Add Video Card</p>
</a>
</li>
</div>
</template>
<script>
export default {
computed: {

},
methods: {
imagecard(val) {
//how to add image card
},
videocard() {
//how to add video card
}
},

}
</script>


ImageCard.vue



<template>
<h1> I am a image Card </h1>
</template>
<script>

</script>


VideoCard.vue



<template>
<h1> I am a Video Card </h1>
</template>
<script>

</script>


I need to add components dynamically one after another in the <div id="dynamic_components"> . User can add as many as cards they want.



How do I add the components dynamically. Please point me to a tutorial.










share|improve this question


















  • 1





    Keep data-driven in mind. for your cases, define one array as data/computed property=cards like [{'card-content':{}, 'card-type':'image'}, {'card-content':{}, 'card-type':'image'}], then in your template, <div> <!-- add components here --><template v-for="(card, index) in cards" :key="index" :is="card['card-type']"></template> </div>

    – Sphinx
    Jun 1 '18 at 21:02













  • @Sphinx , so each time the user clicks the button , I need to push the new array element in the computed property and v-for will take care of rendering it on the UI.

    – Stacy Thompson
    Jun 1 '18 at 21:10











  • @Sphinx Please write an answer, you just provided a great answer but as a comment...

    – Bernardo Duarte
    Jun 1 '18 at 21:13














1












1








1








I have three templates. AddCard.vue , ImageCard.vue and VideoCard.vue



AddCard.vue has two buttons on it one is to add the Image Card and Other To Add the video Card.. I need to add components based on the button click. Here are three templates and my index.html file.



index.html



   <!doctype html>
<html lang="en">
<head>

</head>
<body>
<div id="app">
<div class="container">
<div id="dynamic_components">
<!-- add components here -->
</div>
<addcard></addcard>
</div>
</div>
<script src="{{ asset('js/app.js') }}"></script>
</body>
</html>


AddCard.vue



<template>
<div class="buttons">
ul class="no-margin-list">
<li @click="imagecard">
<span class="card_icon">
<img :src="'img/image.jpg'" >
</span>
<p>Add Image Card</p>
</a>
</li>

<li @click="videocard">
<span class="card_icon">
<img :src="'img/video.jpg'" >
</span>
<p>Add Video Card</p>
</a>
</li>
</div>
</template>
<script>
export default {
computed: {

},
methods: {
imagecard(val) {
//how to add image card
},
videocard() {
//how to add video card
}
},

}
</script>


ImageCard.vue



<template>
<h1> I am a image Card </h1>
</template>
<script>

</script>


VideoCard.vue



<template>
<h1> I am a Video Card </h1>
</template>
<script>

</script>


I need to add components dynamically one after another in the <div id="dynamic_components"> . User can add as many as cards they want.



How do I add the components dynamically. Please point me to a tutorial.










share|improve this question














I have three templates. AddCard.vue , ImageCard.vue and VideoCard.vue



AddCard.vue has two buttons on it one is to add the Image Card and Other To Add the video Card.. I need to add components based on the button click. Here are three templates and my index.html file.



index.html



   <!doctype html>
<html lang="en">
<head>

</head>
<body>
<div id="app">
<div class="container">
<div id="dynamic_components">
<!-- add components here -->
</div>
<addcard></addcard>
</div>
</div>
<script src="{{ asset('js/app.js') }}"></script>
</body>
</html>


AddCard.vue



<template>
<div class="buttons">
ul class="no-margin-list">
<li @click="imagecard">
<span class="card_icon">
<img :src="'img/image.jpg'" >
</span>
<p>Add Image Card</p>
</a>
</li>

<li @click="videocard">
<span class="card_icon">
<img :src="'img/video.jpg'" >
</span>
<p>Add Video Card</p>
</a>
</li>
</div>
</template>
<script>
export default {
computed: {

},
methods: {
imagecard(val) {
//how to add image card
},
videocard() {
//how to add video card
}
},

}
</script>


ImageCard.vue



<template>
<h1> I am a image Card </h1>
</template>
<script>

</script>


VideoCard.vue



<template>
<h1> I am a Video Card </h1>
</template>
<script>

</script>


I need to add components dynamically one after another in the <div id="dynamic_components"> . User can add as many as cards they want.



How do I add the components dynamically. Please point me to a tutorial.







vue.js






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jun 1 '18 at 20:48









Stacy ThompsonStacy Thompson

167111




167111








  • 1





    Keep data-driven in mind. for your cases, define one array as data/computed property=cards like [{'card-content':{}, 'card-type':'image'}, {'card-content':{}, 'card-type':'image'}], then in your template, <div> <!-- add components here --><template v-for="(card, index) in cards" :key="index" :is="card['card-type']"></template> </div>

    – Sphinx
    Jun 1 '18 at 21:02













  • @Sphinx , so each time the user clicks the button , I need to push the new array element in the computed property and v-for will take care of rendering it on the UI.

    – Stacy Thompson
    Jun 1 '18 at 21:10











  • @Sphinx Please write an answer, you just provided a great answer but as a comment...

    – Bernardo Duarte
    Jun 1 '18 at 21:13














  • 1





    Keep data-driven in mind. for your cases, define one array as data/computed property=cards like [{'card-content':{}, 'card-type':'image'}, {'card-content':{}, 'card-type':'image'}], then in your template, <div> <!-- add components here --><template v-for="(card, index) in cards" :key="index" :is="card['card-type']"></template> </div>

    – Sphinx
    Jun 1 '18 at 21:02













  • @Sphinx , so each time the user clicks the button , I need to push the new array element in the computed property and v-for will take care of rendering it on the UI.

    – Stacy Thompson
    Jun 1 '18 at 21:10











  • @Sphinx Please write an answer, you just provided a great answer but as a comment...

    – Bernardo Duarte
    Jun 1 '18 at 21:13








1




1





Keep data-driven in mind. for your cases, define one array as data/computed property=cards like [{'card-content':{}, 'card-type':'image'}, {'card-content':{}, 'card-type':'image'}], then in your template, <div> <!-- add components here --><template v-for="(card, index) in cards" :key="index" :is="card['card-type']"></template> </div>

– Sphinx
Jun 1 '18 at 21:02







Keep data-driven in mind. for your cases, define one array as data/computed property=cards like [{'card-content':{}, 'card-type':'image'}, {'card-content':{}, 'card-type':'image'}], then in your template, <div> <!-- add components here --><template v-for="(card, index) in cards" :key="index" :is="card['card-type']"></template> </div>

– Sphinx
Jun 1 '18 at 21:02















@Sphinx , so each time the user clicks the button , I need to push the new array element in the computed property and v-for will take care of rendering it on the UI.

– Stacy Thompson
Jun 1 '18 at 21:10





@Sphinx , so each time the user clicks the button , I need to push the new array element in the computed property and v-for will take care of rendering it on the UI.

– Stacy Thompson
Jun 1 '18 at 21:10













@Sphinx Please write an answer, you just provided a great answer but as a comment...

– Bernardo Duarte
Jun 1 '18 at 21:13





@Sphinx Please write an answer, you just provided a great answer but as a comment...

– Bernardo Duarte
Jun 1 '18 at 21:13












1 Answer
1






active

oldest

votes


















2














Uses v-for + dynamic component.






Vue.config.productionTip = false

Vue.component('card1', {
template: '<div>Card:<span style="background-color:green">{{title}}</span></div>',
props: ['title']
})

Vue.component('card2', {
template: '<div>Card:<span style="background-color:blue">{{title}}</span></div>',
props: ['title']
})

Vue.component('card3', {
template: '<div>Card:<span style="background-color:yellow">{{title}}</span></div>',
props: ['title']
})

new Vue({
el: '#app',
data() {
return {
cards: [
{'card': {'title': 'I am one card1'}, 'card-type':'card1'},
{'card': {'title': 'I am one card2'}, 'card-type':'card2'}
]
}
},
computed: {
computedNoCard1: function () {
let availableCards = new Set(['card2', 'card3'])
return this.cards.filter((item) => {
return availableCards.has(item['card-type'])
})
}
},
methods: {
addCard: function () {
let supportedCards = ['card1', 'card2', 'card3']
let seed = Math.floor(Math.random()*supportedCards.length)
this.cards.push({'card': {'title': 'I am new card for ' + supportedCards[seed]}, 'card-type': supportedCards[seed]})
}
}
})

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.16/vue.js"></script>
<div id="app">
<button @click="addCard()">Add Card</button>
<table>
<tr><th>Data Property</th><th>Computed Property</th></tr>
<tr>
<td>
<div v-for="(card, index) in cards" :key="index">
<component :is="card['card-type']" :title="card.card.title">
</component>
</div>
</td>
<td>
<div v-for="(card, index) in computedNoCard1" :key="index">
<component :is="card['card-type']" :title="card.card.title">
</component>
</div>
</td>
</table>

</div>








share|improve this answer


























  • how do I pass the values from app.js to the template files. For example how to pass the value of message to the ImageCard.vue template file. When the user clicks the Image Card.

    – Stacy Thompson
    Jun 2 '18 at 19:34











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50650815%2fvue-add-a-component-on-button-click%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














Uses v-for + dynamic component.






Vue.config.productionTip = false

Vue.component('card1', {
template: '<div>Card:<span style="background-color:green">{{title}}</span></div>',
props: ['title']
})

Vue.component('card2', {
template: '<div>Card:<span style="background-color:blue">{{title}}</span></div>',
props: ['title']
})

Vue.component('card3', {
template: '<div>Card:<span style="background-color:yellow">{{title}}</span></div>',
props: ['title']
})

new Vue({
el: '#app',
data() {
return {
cards: [
{'card': {'title': 'I am one card1'}, 'card-type':'card1'},
{'card': {'title': 'I am one card2'}, 'card-type':'card2'}
]
}
},
computed: {
computedNoCard1: function () {
let availableCards = new Set(['card2', 'card3'])
return this.cards.filter((item) => {
return availableCards.has(item['card-type'])
})
}
},
methods: {
addCard: function () {
let supportedCards = ['card1', 'card2', 'card3']
let seed = Math.floor(Math.random()*supportedCards.length)
this.cards.push({'card': {'title': 'I am new card for ' + supportedCards[seed]}, 'card-type': supportedCards[seed]})
}
}
})

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.16/vue.js"></script>
<div id="app">
<button @click="addCard()">Add Card</button>
<table>
<tr><th>Data Property</th><th>Computed Property</th></tr>
<tr>
<td>
<div v-for="(card, index) in cards" :key="index">
<component :is="card['card-type']" :title="card.card.title">
</component>
</div>
</td>
<td>
<div v-for="(card, index) in computedNoCard1" :key="index">
<component :is="card['card-type']" :title="card.card.title">
</component>
</div>
</td>
</table>

</div>








share|improve this answer


























  • how do I pass the values from app.js to the template files. For example how to pass the value of message to the ImageCard.vue template file. When the user clicks the Image Card.

    – Stacy Thompson
    Jun 2 '18 at 19:34
















2














Uses v-for + dynamic component.






Vue.config.productionTip = false

Vue.component('card1', {
template: '<div>Card:<span style="background-color:green">{{title}}</span></div>',
props: ['title']
})

Vue.component('card2', {
template: '<div>Card:<span style="background-color:blue">{{title}}</span></div>',
props: ['title']
})

Vue.component('card3', {
template: '<div>Card:<span style="background-color:yellow">{{title}}</span></div>',
props: ['title']
})

new Vue({
el: '#app',
data() {
return {
cards: [
{'card': {'title': 'I am one card1'}, 'card-type':'card1'},
{'card': {'title': 'I am one card2'}, 'card-type':'card2'}
]
}
},
computed: {
computedNoCard1: function () {
let availableCards = new Set(['card2', 'card3'])
return this.cards.filter((item) => {
return availableCards.has(item['card-type'])
})
}
},
methods: {
addCard: function () {
let supportedCards = ['card1', 'card2', 'card3']
let seed = Math.floor(Math.random()*supportedCards.length)
this.cards.push({'card': {'title': 'I am new card for ' + supportedCards[seed]}, 'card-type': supportedCards[seed]})
}
}
})

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.16/vue.js"></script>
<div id="app">
<button @click="addCard()">Add Card</button>
<table>
<tr><th>Data Property</th><th>Computed Property</th></tr>
<tr>
<td>
<div v-for="(card, index) in cards" :key="index">
<component :is="card['card-type']" :title="card.card.title">
</component>
</div>
</td>
<td>
<div v-for="(card, index) in computedNoCard1" :key="index">
<component :is="card['card-type']" :title="card.card.title">
</component>
</div>
</td>
</table>

</div>








share|improve this answer


























  • how do I pass the values from app.js to the template files. For example how to pass the value of message to the ImageCard.vue template file. When the user clicks the Image Card.

    – Stacy Thompson
    Jun 2 '18 at 19:34














2












2








2







Uses v-for + dynamic component.






Vue.config.productionTip = false

Vue.component('card1', {
template: '<div>Card:<span style="background-color:green">{{title}}</span></div>',
props: ['title']
})

Vue.component('card2', {
template: '<div>Card:<span style="background-color:blue">{{title}}</span></div>',
props: ['title']
})

Vue.component('card3', {
template: '<div>Card:<span style="background-color:yellow">{{title}}</span></div>',
props: ['title']
})

new Vue({
el: '#app',
data() {
return {
cards: [
{'card': {'title': 'I am one card1'}, 'card-type':'card1'},
{'card': {'title': 'I am one card2'}, 'card-type':'card2'}
]
}
},
computed: {
computedNoCard1: function () {
let availableCards = new Set(['card2', 'card3'])
return this.cards.filter((item) => {
return availableCards.has(item['card-type'])
})
}
},
methods: {
addCard: function () {
let supportedCards = ['card1', 'card2', 'card3']
let seed = Math.floor(Math.random()*supportedCards.length)
this.cards.push({'card': {'title': 'I am new card for ' + supportedCards[seed]}, 'card-type': supportedCards[seed]})
}
}
})

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.16/vue.js"></script>
<div id="app">
<button @click="addCard()">Add Card</button>
<table>
<tr><th>Data Property</th><th>Computed Property</th></tr>
<tr>
<td>
<div v-for="(card, index) in cards" :key="index">
<component :is="card['card-type']" :title="card.card.title">
</component>
</div>
</td>
<td>
<div v-for="(card, index) in computedNoCard1" :key="index">
<component :is="card['card-type']" :title="card.card.title">
</component>
</div>
</td>
</table>

</div>








share|improve this answer















Uses v-for + dynamic component.






Vue.config.productionTip = false

Vue.component('card1', {
template: '<div>Card:<span style="background-color:green">{{title}}</span></div>',
props: ['title']
})

Vue.component('card2', {
template: '<div>Card:<span style="background-color:blue">{{title}}</span></div>',
props: ['title']
})

Vue.component('card3', {
template: '<div>Card:<span style="background-color:yellow">{{title}}</span></div>',
props: ['title']
})

new Vue({
el: '#app',
data() {
return {
cards: [
{'card': {'title': 'I am one card1'}, 'card-type':'card1'},
{'card': {'title': 'I am one card2'}, 'card-type':'card2'}
]
}
},
computed: {
computedNoCard1: function () {
let availableCards = new Set(['card2', 'card3'])
return this.cards.filter((item) => {
return availableCards.has(item['card-type'])
})
}
},
methods: {
addCard: function () {
let supportedCards = ['card1', 'card2', 'card3']
let seed = Math.floor(Math.random()*supportedCards.length)
this.cards.push({'card': {'title': 'I am new card for ' + supportedCards[seed]}, 'card-type': supportedCards[seed]})
}
}
})

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.16/vue.js"></script>
<div id="app">
<button @click="addCard()">Add Card</button>
<table>
<tr><th>Data Property</th><th>Computed Property</th></tr>
<tr>
<td>
<div v-for="(card, index) in cards" :key="index">
<component :is="card['card-type']" :title="card.card.title">
</component>
</div>
</td>
<td>
<div v-for="(card, index) in computedNoCard1" :key="index">
<component :is="card['card-type']" :title="card.card.title">
</component>
</div>
</td>
</table>

</div>








Vue.config.productionTip = false

Vue.component('card1', {
template: '<div>Card:<span style="background-color:green">{{title}}</span></div>',
props: ['title']
})

Vue.component('card2', {
template: '<div>Card:<span style="background-color:blue">{{title}}</span></div>',
props: ['title']
})

Vue.component('card3', {
template: '<div>Card:<span style="background-color:yellow">{{title}}</span></div>',
props: ['title']
})

new Vue({
el: '#app',
data() {
return {
cards: [
{'card': {'title': 'I am one card1'}, 'card-type':'card1'},
{'card': {'title': 'I am one card2'}, 'card-type':'card2'}
]
}
},
computed: {
computedNoCard1: function () {
let availableCards = new Set(['card2', 'card3'])
return this.cards.filter((item) => {
return availableCards.has(item['card-type'])
})
}
},
methods: {
addCard: function () {
let supportedCards = ['card1', 'card2', 'card3']
let seed = Math.floor(Math.random()*supportedCards.length)
this.cards.push({'card': {'title': 'I am new card for ' + supportedCards[seed]}, 'card-type': supportedCards[seed]})
}
}
})

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.16/vue.js"></script>
<div id="app">
<button @click="addCard()">Add Card</button>
<table>
<tr><th>Data Property</th><th>Computed Property</th></tr>
<tr>
<td>
<div v-for="(card, index) in cards" :key="index">
<component :is="card['card-type']" :title="card.card.title">
</component>
</div>
</td>
<td>
<div v-for="(card, index) in computedNoCard1" :key="index">
<component :is="card['card-type']" :title="card.card.title">
</component>
</div>
</td>
</table>

</div>





Vue.config.productionTip = false

Vue.component('card1', {
template: '<div>Card:<span style="background-color:green">{{title}}</span></div>',
props: ['title']
})

Vue.component('card2', {
template: '<div>Card:<span style="background-color:blue">{{title}}</span></div>',
props: ['title']
})

Vue.component('card3', {
template: '<div>Card:<span style="background-color:yellow">{{title}}</span></div>',
props: ['title']
})

new Vue({
el: '#app',
data() {
return {
cards: [
{'card': {'title': 'I am one card1'}, 'card-type':'card1'},
{'card': {'title': 'I am one card2'}, 'card-type':'card2'}
]
}
},
computed: {
computedNoCard1: function () {
let availableCards = new Set(['card2', 'card3'])
return this.cards.filter((item) => {
return availableCards.has(item['card-type'])
})
}
},
methods: {
addCard: function () {
let supportedCards = ['card1', 'card2', 'card3']
let seed = Math.floor(Math.random()*supportedCards.length)
this.cards.push({'card': {'title': 'I am new card for ' + supportedCards[seed]}, 'card-type': supportedCards[seed]})
}
}
})

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.16/vue.js"></script>
<div id="app">
<button @click="addCard()">Add Card</button>
<table>
<tr><th>Data Property</th><th>Computed Property</th></tr>
<tr>
<td>
<div v-for="(card, index) in cards" :key="index">
<component :is="card['card-type']" :title="card.card.title">
</component>
</div>
</td>
<td>
<div v-for="(card, index) in computedNoCard1" :key="index">
<component :is="card['card-type']" :title="card.card.title">
</component>
</div>
</td>
</table>

</div>






share|improve this answer














share|improve this answer



share|improve this answer








edited Jun 1 '18 at 21:28

























answered Jun 1 '18 at 21:15









SphinxSphinx

5,44321228




5,44321228













  • how do I pass the values from app.js to the template files. For example how to pass the value of message to the ImageCard.vue template file. When the user clicks the Image Card.

    – Stacy Thompson
    Jun 2 '18 at 19:34



















  • how do I pass the values from app.js to the template files. For example how to pass the value of message to the ImageCard.vue template file. When the user clicks the Image Card.

    – Stacy Thompson
    Jun 2 '18 at 19:34

















how do I pass the values from app.js to the template files. For example how to pass the value of message to the ImageCard.vue template file. When the user clicks the Image Card.

– Stacy Thompson
Jun 2 '18 at 19:34





how do I pass the values from app.js to the template files. For example how to pass the value of message to the ImageCard.vue template file. When the user clicks the Image Card.

– Stacy Thompson
Jun 2 '18 at 19:34


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50650815%2fvue-add-a-component-on-button-click%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

Calculate evaluation metrics using cross_val_predict sklearn

Insert data from modal to MySQL (multiple modal on website)