0

Is it possible, when button triggers this action, it stays on !this.lastMeasure? Because when I click it again, it goes back to the last state. I want it to stay on the new state.

changeMeasure() {
  this.lastMeasure = !this.lastMeasure
}
1
  • 2
    Couldn't you just set it to false? this.lastMeasure = false Commented Aug 10, 2020 at 8:15

1 Answer 1

2

Vue provides event modifiers for the v-on directive. One of these event modifiers is .once, it rules the associated events to be triggered at most once.

You can use this event modifier like :

<!-- the click event will be triggered at most once -->
<a v-on:click.once="doThis"></a>

Then in your case, you may use something like :

<!-- '@' is the shorthand for 'v-on:' -->
<button @click.once="changeMeasure">I am the button</button>

source

Sign up to request clarification or add additional context in comments.

Comments

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.