[Vuejs]-Dynamic style binding in vue js to toggle a class

0👍

It doesn’t make sense to put an expression as a property key.

Try this:

new Vue({
      el: '#app',
      data: {
        cssClass: '',
        text: ''
      },
      methods: {
        onSubmit: function(course) {
          axios.post('/MyCourses/' + course.name)
              //  .then(function (response){
              //  });
          if (course.completed == true) {     
            this.cssClass = 'coursetogglingtrue',
            this.text = 'Done!'
          } else {
            this.cssClass = 'coursetogglingfalse',
            this.text = 'Not Yet!'
          }
        }
      }
  });

Leave a comment