[Vuejs]-Vue.Js โ€“ data not updating

0๐Ÿ‘

โœ…

1 == true //true
1 === true // false

I think the problem may lies in the fact that HTTP returns true, not 1.

๐Ÿ‘คazurinko

0๐Ÿ‘

I think the โ€˜thisโ€™ keyword has different value than you expected. Try this approach:

loadGame: function () {
  let self = this;
  this.$http.get('../api/games/ready/' + self.gameid).then(function (response) {
     if (response.body === '1') {
       var result = Math.floor((Math.random() * 2) + 1);
       self.result = result;
     }
   });
}
๐Ÿ‘คAvi Waserman

Leave a comment