[Vuejs]-How the display the data that nested in the array (Laravel Vue)

0๐Ÿ‘

โœ…

I think the easiest way would be make your column total_bil_year to return as a array via casting from its model. Something like below (if total_billed_by_year column is a json column)

 protected $casts = [
        'total_billed_by_year' => 'array'
    ];

Based on the image you attached to the question shows that it is returned as a json. So you can convert it as object at vue also. Something like below

JSON.parse(tr.total_billed_by_year) which will convert into a array and that array contain the object. See the below image. I just reproduced it at console

enter image description here

you can use it like below. Or just make a function to convert your jsons to objects where you can use it when you want

 </template>{{JSON.parse(tr.total_billed_by_year)[0].bil_year}}

0๐Ÿ‘

baby, using JSON.parse(yourJSONString) to transform your json string to json object.

Leave a comment