Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Vue: V-if with condition

in my vue application I have following code:

<div v-if="partner == true && kids == false" class="row">
   <input type="text" id="testInput">
</div>

Now when I want to try out this code snippet it does not render the input. I am pretty sure it should because the variables have the right value at this moment.

I also tried this but this does not work either:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

<div v-if="partner && !kids" class="row">
   <input type="text" id="testInput">
<div>

Is the condition wrong or what is the problem with this code?

>Solution :

Your code is fine:

new Vue({
  el: "#demo",
  data() {
    return {
      partner: true,
      kids: false
    }
  }
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="demo">
  <div v-if="partner && !kids" class="row">
   <input type="text" id="testInput">
  </div>
</div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading