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

192
Views
vuejs multiple v-if on one element

sup, so I have a problem with v-if in vue.

basicly I have a v-for that loops thru array and inside that v-for I have a couple of elements with v-if

<button v-if="Collection.status" type="button">deactivate</button>
<button v-else type="button">activate</button>

but I would also like to disable "activate" buttons if a data variable (disableButton) is true. How could I do that?

Its maybe a silly question but im new to vue and i have been searching for this for to long.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Try like following snippet:

new Vue({
  el: '#demo',
  data() {
    return {
      Collections: [{id: 1, status: true}, {id: 2, status: false}, {id: 3, status: true}],
      disableButton: true
    }
  }
})

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">
  <ul>
    <li v-for="Collection in Collections" :key="Collection.id">
      <button v-if="Collection.status" type="button" >deactivate</button>
      <button v-else :disabled="disableButton" type="button">activate</button>
    </li>
  </ul>
</div>

about 4 years ago · Juan Pablo Isaza Report

0

are you looking for this?

<button v-else type="button" disable="Collection.disableButton">activate</button>
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!