Vue.js Adding a class by using computed

I am a beginner at Vue.js. I would like to add a class, which depends on conditionals.
I wanna remove the success class when the answer is greater than 25, but the color doesn’t change… could you please give me any advice?

<!DOCTYPE html>
<html lang="en">
   <head>
      <meta charset="UTF-8" />
      <meta name="viewport" content="width=device-width, initial-scale=1.0" />
      <title>Caliculator</title>
   </head>
   <body>
      <div id="app">
         <input type="number" name="num1" v-model.number="num1" /> +
         <input type="number" name="num2" v-model.number="num2" /> +
         <input type="number" name="num3" v-model.number="num3" /> +
         <input type="number" name="num4" v-model.number="num4" /> +
         <input type="number" name="num5" v-model.number="num5" /> =
         <span class="error" :class="classObject">{{ answer }}</span>
      </div>

      <style>
         .success {
            color: green;
         }
      </style>
      <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
      <script>
         var app = new Vue({
            el: "#app",
            data: {
               num1: 0,
               num2: 0,
               num3: 0,
               num4: 0,
               num5: 0,
               classObject: {
                  success: true,
               },
            },
            computed: {
               answer: function () {
                  return (
                     this.num1 + this.num2 + this.num3 + this.num4 + this.num5
                  );
               },
               classObject: function () {
                  if (this.answer > 25) {
                     success: false;
                  }
               },
            },
         });
      </script>
   </body>
</html>

172 thoughts on “Vue.js Adding a class by using computed”

  1. I have been surfing on-line more than three hours as of late, yet I by no means found any attention-grabbing article like yours.
    It is pretty price enough for me. In my opinion, if all
    site owners and bloggers made excellent content material as you did, the internet shall be a lot more helpful than ever before.

    Reply
  2. Aw, this was an exceptionally good post. Taking a few minutes and actual effort to make a top notch article… but what can I
    say… I procrastinate a whole lot and don’t manage to get anything done.

    Reply
  3. Thanks for your posting. I also feel that laptop computers have become more and more popular lately, and now tend to be the only kind of computer utilized in a household. The reason is that at the same time potentially they are becoming more and more reasonably priced, their processing power is growing to the point where they may be as strong as desktop through just a few years back.

    Reply
  4. Hi, I do believe this is a great website. I stumbledupon it 😉 I’m going to come back yet again since i have book marked it.
    Money and freedom is the greatest way to change, may you be rich and continue to help others.

    Reply
  5. It is perfect time to make some plans for the future and it is time to be happy.
    I have read this post and if I could I desire to suggest you some interesting things or tips.
    Maybe you can write next articles referring to this article.
    I want to read more things about it!

    Reply
  6. It’s perfect time to make some plans for the future and it’s time to be happy.
    I have read this post and if I could I desire to suggest you few interesting things or suggestions.

    Perhaps you can write next articles referring to this article.
    I desire to read more things about it!

    Reply
  7. Hello, i read your blog occasionally and i own a similar
    one and i was just wondering if you get a lot of spam remarks?
    If so how do you reduce it, any plugin or anything you can advise?
    I get so much lately it’s driving me insane so any support is
    very much appreciated.

    Reply
  8. Hey there! Someone in my Facebook group shared
    this website with us so I came to give it a look. I’m definitely enjoying the information. I’m book-marking and will
    be tweeting this to my followers! Exceptional blog and amazing
    design.

    Reply
  9. Hey would you mind letting me know which web host you’re
    using? I’ve loaded your blog in 3 completely different browsers and I must say this blog loads a lot quicker then most.
    Can you suggest a good hosting provider at a
    honest price? Cheers, I appreciate it!

    Reply
  10. I have been browsing online greater than 3 hours lately,
    but I by no means found any attention-grabbing article like yours.
    It is beautiful worth sufficient for me. In my opinion, if all
    website owners and bloggers made excellent content material as you did, the
    net can be much more useful than ever before.

    Reply
  11. Hi, Neat post. There’s a problem along with your website
    in web explorer, may test this? IE still is the marketplace
    leader and a big portion of other people will omit
    your wonderful writing because of this problem.

    Reply
  12. I have been browsing online more than 2 hours today, yet I never found
    any interesting article like yours. It is pretty worth enough for me.
    In my view, if all web owners and bloggers made good content as you did, the internet will be a lot more useful than ever before.

    Reply
  13. Pingback: purchase viagra
  14. Pingback: sildenafil citrate
  15. It is perfect time to make some plans for the long run and it
    is time to be happy. I’ve learn this publish and if I could I desire to recommend you some attention-grabbing issues or suggestions.
    Maybe you can write subsequent articles regarding this
    article. I desire to learn even more things about it!

    Reply
  16. Pingback: viagra online
  17. Hi! Someone in my Facebook group shared this website with us so I came to take a look.
    I’m definitely loving the information. I’m bookmarking and will be tweeting this to my followers!
    Great blog and outstanding design.

    Reply
  18. Pingback: cialis uk
  19. Pingback: buy generic cialis
  20. Pingback: cialis usa
  21. Pingback: viagra samples
  22. Pingback: canadian viagra
  23. Pingback: viagra 4 tablets
  24. Pingback: sildenafil 50mg
  25. Pingback: cialis generic
  26. Pingback: generic for viagra
  27. Pingback: viagra pricing
  28. Pingback: viagra usa
  29. Pingback: research tadalafil
  30. Pingback: cialis rezeptfrei
  31. Pingback: homemade viagra
  32. Pingback: sildenafil coupon
  33. Pingback: buy generic viagra
  34. Pingback: viagra pornhub
  35. Pingback: herbal viagra
  36. Pingback: viagra kopen
  37. Pingback: viagra homme
  38. Pingback: walmart viagra
  39. Pingback: sildenafil teva
  40. Pingback: viagra pill
  41. Pingback: viagra sildenafil
  42. Pingback: viagra generic
  43. Pingback: pfizer viagra

Leave a Comment