How can I hide input when I click on a button? Hide without using styles (like document.getElem....id('test').style.display = "none" (or visible = 'hidden'))
|
1 answer
<div> <input v-if="inputVisibility" type="text"> <button @click="hideInput">Hide input</button> </div> data() { return { inputVisibility: true } }, methods: { hideInput() { this.inputVisibility = false; // или можно тоггл // this.inputVisibility = !this.inputVisibility; } } There is also a v-show directive. The difference is that v-if does not render, if the condition is false , and v-show renders, but in css it writes display: none . Read more here https://ru.vuejs.org/v2/guide/conditional.html
|