Notes: Use axios to call data and render in vue

Original link: https://zburu.com/archives/151.html

Examples are as follows.

 <template> <div class="posts"> <div v-for="item in list" :key="item.cid" > </div> </div> </template> <script> import Axios from 'axios'; export default { name: 'index', data () { return { list: [] } }, methods: { getData () { var api = 'https://zburu.com/api/posts.php'; Axios.get(api).then((response) => { this.list = response.data; console.log(response.data) }).catch((error) => { console.log(error); }) } }, mounted () { this.getData(); }, } </script> <style> </style>

This article is reproduced from: https://zburu.com/archives/151.html
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment