0

Using vuejs 3. In the vuejs app, I have:

data(){
    return{
        return_prohibited:false
    }
}

return_prohibited turns to true when the server returns an error message from a fetch request:

fetch(myUrl,this.myInit)
     .then(response => response.json())
     .then(data => {
          if (data.message) {
              this.credits = []
              this.debits = []
              return_prohibited = true
         } // cut for brievity

Html file:

<button @click="previousMonth" id="bouton_mois_prec" :class="{interdit:return_prohibited}" >précédent</button>

I was expecting that the css class interdit would be added to the button each time that return_probibited is true, as per these explanations. But nothing happens.

2
  • What changes return_prohibited? Commented Mar 7, 2021 at 17:01
  • I have updated the question with this. Commented Mar 7, 2021 at 17:08

1 Answer 1

1

You should append this. in front of return_prohibited - otherwise you will get errors in the console.

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.