Source code
<template>
<div class="header">
<div v-for="(val,index) in list" :key="index">
<ul>
<li>{{val.name}}</li>
<li></li>
</ul>
</div>
</div>
</template>
<script>
import axios from "axios"
export default {
name: "axiso",
data() {
return {
list: [],
}
},
mounted() {
this.getJson()
console.log(this.list)
},
methods: {
getJson() {
console.log(this)
const url = "http://localhost:8080/api"
axios.get(url).then(res => {
this.list = res.data
console.log(this.list, "------");
});
},
}
}
</script>
<style>
</style>
can also get the data, but it just can"t be rendered to the page