-
-
Save Aybee5/a6f9cef26962dedc9bd79a8ad0524d22 to your computer and use it in GitHub Desktop.
App.vue -> axios
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <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> |
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
Make edits to the tags by specifying their opening and closing tags