0

Since I have to change state.active from false to true alot through @click, I was wondering if there is a shorter way in doing so than:

state.active = !state.active

I've tried @click="!state.active" which doesn't seem to work.

Artur Müller Romanov
  • 2,304
  • 3
  • 30
  • 64
  • I don't think there is a shorter way. Check out this question https://stackoverflow.com/questions/13972887/shorthand-for-flipping-a-boolean-variable?noredirect=1&lq=1 But if you toggle this variable in a lot of different places, you may consider moving this logic to a vue method and use something like @click="toggleState" in your template – Romalex Feb 23 '22 at 18:41

0 Answers0