N
N
Nikolai Nikolaev2019-01-17 10:25:08
Vue.js
Nikolai Nikolaev, 2019-01-17 10:25:08

Close button on vue.js?

Good afternoon. I'm starting to get acquainted with vue.js and I don't understand how to correctly describe the method for the element's close button.
That is, make one common close button for two different windows with absolute positioning, because when opened, windows overlap the visibility area of ​​the open
HTML buttons:

<div id="app">
<div class="app">
<div class="buttons-open">
<!-- Кнопки которые открывают блоки -->
<a @click='open1 = !open1'>открыть первый блок</a>
<a @click='open2 = !open2'>открыть второй блок</a>
</div>
<div class="block-1" v-if='open1'>
<a @click="close">Скрыть блок</a>
<div class="content">Первый блок</div>
</div>
<div class="block-2" v-if='open2'>
<a @click="close">Скрыть блок</a>
<div class="content">Второй блок</div>
</div>
</div>
</div>

vue.js:
new Vue({
el: '#app',
data: {
open1: false,
open2: false
}
})

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Proskurin, 2019-01-17
@kot9ra161

It's not very clear from the question. Do you want an implementation of the close method?

new Vue({
el: '#app',
data: {
open1: false,
open2: false
},
methods: {
  close: function() {
    this.open1 = false;
    this.open2 = false;
  }
}
})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question