Skip to content

Instantly share code, notes, and snippets.

@Aybee5
Forked from spemer/App.vue
Last active October 14, 2019 18:08
Show Gist options
  • Save Aybee5/a6f9cef26962dedc9bd79a8ad0524d22 to your computer and use it in GitHub Desktop.
Save Aybee5/a6f9cef26962dedc9bd79a8ad0524d22 to your computer and use it in GitHub Desktop.
App.vue -> axios
<template lang="pug">
<div id="app">
<div
v-for="user in users"
:key="users.id"
>
<h1> {{ user.name }} </h1>
<p> {{ user.email }} </p>
<button> (@click="fetchUsers") Click me! </button>
</div>
</template>
<script>
export default {
name: 'app',
data () {
return {
users: []
}
},
methods: {
fetchUsers: function () {
const baseURI = 'https://jsonplaceholder.typicode.com/users'
this.$http.get(baseURI)
.then((result) => {
this.users = result.data
})
}
}
}
<script>
<style lang="scss">
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: left;
width: 640px;
margin: 0 auto;
color: #2c3e50;
margin-top: 60px;
}
</style>
@Aybee5
Copy link
Author

Aybee5 commented Oct 14, 2019

Make edits to the tags by specifying their opening and closing tags

@Aybee5
Copy link
Author

Aybee5 commented Oct 14, 2019

Adds the ending tag of the root tag(div)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment