0

I now tried this code :

<pre id="index1" v-bind:class="[isActive ? 'shown' : 'hidden']" @click="isActive = !isActive">
  {{item.proposalResponse.insertObjects[0]}}
</pre>

...

data() {
  return {
    isActive: false
  };

...
<style>
  .hidden{
    height: 40px;
    overflow: hidden;
    background-color: powderblue;
  }
  .shown {
    background-color: powderblue;
  }
</style>

The problem with this code is that it generates a lot of these element and all of them toggle at the same time.

I would like to have it so only the element i click will toggle.

I am new to both js and vue.js so please be kind :)

2
  • the answers under Vue: toggle each of elements introduce many solutions for your question. Commented Sep 22, 2020 at 23:46
  • Thanks. solved it by taking it out to a component instead :) Commented Sep 23, 2020 at 11:31

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.