Advertisement
Guest User

Untitled

a guest
Jan 29th, 2020
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var dataURL = 'https://jsonplaceholder.typicode.com/posts';
  2.  
  3. var App = new Vue({
  4.   el: '#app',
  5.   data: {
  6.     posts: [] // initialize empty array
  7.   },
  8.   mounted() { // when the Vue app is booted up, this is run automatically.
  9.     var self = this // create a closure to access component in the callback below
  10.     $.getJSON(dataURL, function(data) {
  11.       self.posts = data;
  12.     });
  13.   }
  14. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement