I have a parent and two child components. The first child is a product card, the second one is a modal window. I want clicking to card send true value to modal and show it. Here is a template from my App.vue component:
<template>
<div id="app">
<div class="region" v-for="region in regions" :key="region">
<h2 v-text="region"></h2>
<div class="deputates">
<deputy
class="deputy"
v-for="deputy in deputates_in_regions(region)"
:key="deputy.id"
:deputy="deputy"
@click="open_modal"
></deputy>
</div>
</div>
<modal
class="modal"
v-for="deputy in deputates"
:key="deputy.id"
:deputy="deputy"
:modal_open="modal_open"
></modal>
</div>
</template>
open_modal is false by default:
export default {
name: "app",
data () {
return {
modal_open: false
I want to make it true:
open_modal() {
this.modal_open = true
}
Recieve it in component:
export default {
name: "modal",
props: {
deputy: Object,
modal_open: {
type: Boolean,
required: true
}
}
And show a modal window:
<template>
<div class="modal" v-show="modal_open">
<p>{{ deputy.modal }}</p>
</div>
</template>
But my code doesn't work.