I'm new to vuejs and trying to use the buefy library.
Error :
Invalid prop: type check failed for prop "data". Expected Array, got Object
<template>
    <b-table :data="data" :columns="columns"></b-table>
</template>
<script>
    export default {
        data() {
            return {
                data: this.data,
                columns: [
                    {
                        field: 'name',
                        label: 'Name',
                    },
                ]
            }
        },
        mounted() {
            axios
            .get('/test')
            .then(
                response => (this.data = response)
            )
        }
    }
</script>
The json content:
[{"name":"test"}]
What did I miss? Thx :)
The declaration of data property should be as below:
 data: []
Updated code:
<script>
export default {
    data() {
        return {
            data: [],
            columns: [
                {
                    field: 'name',
                    label: 'Name',
                },
            ]
        }
    },
    mounted() {
        axios
        .get('/test')
        .then(
            response => (this.data = response)
        )
    }
}
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With