I asked you another question about axios.

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>

console.log

console.log

can also get the data, but it just can"t be rendered to the page

Dec.06,2021

there's something wrong with your list format, it's not an array. So the cycle doesn't come out. The JSON returned by


API is not in the correct format


look at your screenshot. console.log prints this.list is {{'id':1,'name':''}, {},} , which seems to be in the wrong format.

normal json format data is printed like this:

try converting the data format let data = JSON.parse (res.data) , or give it to the back end to the correct json format.


VUE direct array assignment does not trigger an attempt to update. Push the data into list to trigger an attempt to update.


use JSON.parse () to convert json strings into json objects

axios({
    url: url,
    method: 'get'
}).then( res => {
    let data = JSON.parse(res.data)
    this.list = data
})


you don't use es6, where you can't use this to point to the content defined in your data.
you add let that = this; to the axios to see if it works.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3e138-2bb60.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3e138-2bb60.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?