M
M
Mike2018-10-23 16:28:09
Vue.js
Mike, 2018-10-23 16:28:09

How to correctly change true to false and vice versa?

I have a function (click_on_button) that changes false to true. I do not understand how to make this value change by pressing a button, depending on what is set on the server. Now my function looks like this:

foo() {
      var mydata = {'sound': true}
      var id = this.profile.id
      this.$store.dispatch('EDIT_PROFILE', {id, mydata})
}

I think I need to first check my store(profile.sound) if set to true send false to the server. Or vice versa.
How to do it easier?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Yarkov, 2018-10-23
@google_online

var mydata = {'sound': !this.profile.sound}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question