Answer the question
In order to leave comments, you need to log in
How to work with components in vue.js?
Good afternoon!
How to work with properties and methods of the connected StoreModalComponent component?
I try through StoreModalComponent.showModal = true; but it throws an error
<template>
<div>
<button @click="openStore">Открыть склад</button>
<store-modal-component></store-modal-component>
</div>
</template>
<script>
import StoreModalComponent from './StoreModalComponent'
import axios from 'axios'
export default {
data() {
return {}
},
components: {
StoreModalComponent
},
mounted: function () {},
computed: {},
methods: {
openStore: function() {
StoreModalComponent.showModal = true;
},
},
watch: {},
}
</script>
<template>
<div>
<transition name="modal">
<div class="modal-mask" v-if="showModal" @close="showModal = false">
<div class="modal-wrapper">
<div class="modal-container">
<div class="modal-header">
<slot name="header">
Склад
<button class="modal-default-button" @click="$emit('close')">
×
</button>
</slot>
</div>
<div class="modal-body">
<slot name="body">
</slot>
</div>
</div>
</div>
</div>
</transition>
</div>
</template>
<script>
export default {
data() {
return {
showModal: false
}
},
methods: {}
}
</script>
Answer the question
In order to leave comments, you need to log in
export default {
props: {
showModal:{ type: Boolean, default: false }
}
}
<template>
<store-modal-component :show-modal="showModal" />
</template>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question