Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

167
Views
Hide Div based on value of props

I have imported props from my parent.vue. Now I want to hide my div based on the number in my Object.

If my props number is empty or 0 i want to hide this Div, if it is bigger or equal than 1 I want to show it.

Here is how my object looks like which I get from my methods:

enter image description here

my template:

<template>
  <div class='row mb-5'> <!-- HIDE THIS COMPLETE DIV -->
    <div class='col-12'>   
    </div>
  </div>
</template>

my script:

data: function() {
    var data = { 
      checkNumber: this.number,
    }
    console.log(data);
    return data;
  },

props: [
  "number"
  ]
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can use v-if or v-show:

Vue.component('Child', {
  template: `
    <div class='row mb-5' v-if="Number(number) > 0"> 
      <div class='col-12'> 
      number > 0
      </div>
    </div>
  `,
  data() {
    return { 
      checkNumber: this.number,
    }
  },
  props: [
    "number"
  ]
})

new Vue({
  el: '#demo',
  data() {
    return { 
      numbers: 0,
    }
  },
})

Vue.config.productionTip = false
Vue.config.devtools = false
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="demo">
  <input type="number" v-model="numbers" />
  <Child :number="numbers" />
</div>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!