[Vuejs]-How can I get the value from this multiple array object with VueJs

0👍

Do you get your data from API or do you send data to this component using props?
if you use these things you will get undefined it’s because the array doesn’t have a value when you want to get value. you have to wait to data be assigned to the array. you can use this to fix the problem. test with this code:

<template v-if="total_values && total_values.length > 0">
    {{  total_values[0][1].total_collection }} 
</template>

0👍

The posted code works: see this playground. Your problem is elsewhere.

<script setup>
import { ref } from 'vue'
const array = ref([
  [{total_collection: 537600, date: "2022-03-01"}, {total_collection: 260700, date: "2022-03-02"}],
  [{total_collection: 349300, date: "2022-03-01"}, {total_collection: 321300, date: "2022-03-02"}]
])
</script>
<template>
  {{array[0][1].total_collection}}
</template>

Leave a comment