[Vuejs]-All section toggle issue in vuejs

1👍

If using worker.id to identify which worker’s section to expand:

<div class="body" v-show="showSection === worker.id">
  <li v-for="item in worker.services.slice(2)">
    {{ item}}
  </li>
</div>

and

<button @click="toggle(worker.id)">Toggle</button>

and

<script>
methods: {
    toggle(workerId) {
      if (this.showSection === workerId) {
        this.showSection = null
      } else {
        this.showSection = workerId
      }
    }
  },

Leave a comment