示例如下。
代码语言:javascript复制<template>
<div class="posts">
<div
v-for="item in list"
:key="item.cid"
>
{{ item.title }}
</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>