json_test.vue
<template> <div class="container"> <div> <!-- <logo /> --> <div class="title"> {{ title }} </div> <div class="subtitle"> {{ msg }} </div> <p class="html_data"> {{json_data}} </p> <table> <tr> <th>user id</th> <td>{{json_data.userId}}</td> </tr> <tr> <th>id</th> <td>{{json_data.id}}</td> </tr> <tr> <th>title</th> <td>{{json_data.title}}</td> </tr> <tr> <th>body</th> <td>{{json_data.body}}</td> </tr> </table> </div> </div> </template> <script> const axios = require('axios'); let url = "https://jsonplaceholder.typicode.com/posts/1"; export default { data: function(){ return { title:'AXIOS', msg: 'GET JSON', }; }, asyncData: async function(){ let ret = await axios.get(url); return { json_data: ret.data }; } } </script> <style> .container { margin: 0 auto; min-height: 100vh; display: flex; justify-content: center; align-items: center; text-align: center; } .title { font-family: 'Quicksand', 'Source Sans Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; display: block; font-weight: 300; font-size: 20px; color: #35495e; letter-spacing: 1px; padding-bottom: 5px; } .subtitle { font-weight: 300; font-size: 14px; color: #526488; word-spacing: 5px; padding-bottom: 15px; } .links { padding-top: 15px; } </style>