Vue.js Using "this" in Vue RIGHT! Use an arrow function.

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

new Vue({
  el:"#star-wars-people",
  data:{
    people: null
  },
  mounted: function(){
    $.getJSON("http://swapi.co/api/people/", data => this.people = data.results);
  }
})

Caution! Arrow functions are a syntax introduced in Ecmascript 2015. It is not yet supported but all modern browsers, so only use it if you are targetting a browser you know supports it, or if you are compiling your javascript down to ES5 syntax using something like babel.



Got any Vue.js Question?