DigitMagazine

Vue.js main Code with Components

Jul 25th, 2017
82
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const app = new Vue({
  2. el: '#app',
  3. template: `<div>
  4. <search-bar @search="search" />
  5. <ul>
  6. <github-user v-for="user in users"
  7. :user="user"
  8. :key="user.id"/>
  9. </ul>
  10. </div>`,
  11. data: {
  12. users: []
  13. },
  14. methods: {
  15. search: function(query) {
  16. fetch('https://api.github.com/search/users\?q\=' + query)
  17. .then((response) => response.json())
  18. .then((json) => { this.users = json.items });
  19. }
  20. }
  21. });
RAW Paste Data