S
S
Smeecy Smeecy2019-10-21 16:47:01
Vue.js
Smeecy Smeecy, 2019-10-21 16:47:01

Modal window in vue?

I'm trying to make a modal window on VUE.js myself (I'm just learning), can someone tell me what I'm doing wrong?
app.vue

<template>
  <div id="app">
    <Header />
    <Modal />
    <modal v-if="showModalLogin" @close="showModalLogin = false"></modal>
  </div>
</template>

<script>
  import Header from '@/components/Header.vue'
  import Modal from '@/components/Modal.vue'
  export default {
    components: {
      Header,
      Modal
    },
    data() {
      return {
        showModalLogin: false
      }
    }
  }
</script>

modal.vue
<template>
    <transition name="modal">
        <div class="modal-mask">
            1
        </div>
  </transition>
</template>
<script>
export default {
    name: 'Modal'
};
</script>

Header.vue
<template>
    <div class="page">
        <header class="header">
            <div class="container header-container">
                <div class="flex">
                    <div class="header-actions col-3l flex">
                        <button class="button header-actions__button-login" id="showModalLogin" @click="showModalLogin = true">Войти</button>
                        <button class="button header-actions__button-reg" id="showModalReg" @click="showModalReg = true">Регистрация</button>
                    </div>
                </div>
            </div>
        </header>
    <router-view/>
    </div>
</template>

<script>
    export default {
        name: 'Header'
    };
</script>

Answer the question

In order to leave comments, you need to log in

3 answer(s)
X
xversus, 2019-10-21
@Wekeed

1. It is not clear what your modal is, how it differs from Modal, and where the close event that it listens for should be called.
2. You are trying to update data from another component in the header.

M
matiaspub, 2019-10-22
@matiaspub

https://medium.com/js-dojo/component-communication...
And Vuex

S
segio_tt, 2019-10-22
@art055

I do all this on vuetify, it's easy and simple, even many things go like copy-paste

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question