Initial question: I am using a modal window in vue.js, which is launched from the parent module with the following code:
<button v-on:click="openModal">Begin</button>
<Account v-if="showModal" :showModal=showModal></Account>
The openModal function consists of the following:
openModal () {
this.showModal = true
}
The modal window, which consists of a vue component (named Account), is opening properly. However, I would like to pass a variable to my component as a parameter, but I am not sure how to implement this.
Modified code which answers my initial question. I have added the :var="var" props parameter to the Account module.
<button v-on:click="openModal()">Begin</button>
<Account v-if="showModal" :var="var" :showModal=showModal></Account>
And needed to also add the "var: variable" to the data:
data () {
return {
var: variable,
showModal: false
}
}
And, finally the props in the component:
props: ['var']
v-on:clickeddoesn't exist. You probably meantv-on:click( shorthand:@click).onChildClickis defined, what isclicked, when is it emitted and where you expect the data (to/from).:showModal=showModal