Visualizing data from an array within a different Vue component: A step-by-step guide

In my Vue app, I have successfully sent an array from one component to another. However, I am now facing a challenge in visually displaying this data. The issue arises when trying to extract and display specific values, like the date itself. Despite being able to log the data, attempting to access individual properties results in a "cannot read property" error. I attempted to iterate through the parent array, but encountered the same error.

If anyone could provide some guidance on how to resolve this issue, I would greatly appreciate it.

Within the child component's method that fills the array with data:

data: () => ({
    selectedTime: [],
    dates: [{date : new Date().toISOString().substr(0,10), time: []}],
  }),
  
  methods:{
      addTimeFields(){
        this.selectedTime.push({
          startTime:"",
          endTime: "",
        })
        
        this.dates[0].time.push(this.selectedTime)
      },

In the parent component, I am able to successfully receive the array passed from the child (save method). However, when attempting to loop through the array for display purposes, I encounter an error:

<v-card-text v-for="(i,index) in finalDate">
      <v-btn>
        {{i.finalDate}}
      </v-btn>

    </v-card-text>

    <v-divider class="mx-4"></v-divider>

    <v-card-actions>
      <v-spacer />

      <v-col>
        <vs-button>Generate Meeting Link</vs-button>

      </v-col>
      {{finalDate}}
    </v-card-actions>
  </v-card>
</template>

<script>
import MeetingsTableComponent from "@/components/MeetingsTableComponent";
import DatePickerComponent from "@/components/DatePickerComponent";

export default {
  name: "NextMeetingCardComponent",
  components: { DatePickerComponent },
  data: () => ({
    dialog: false,
    finalDate: [],
    menu: false,
    modal: false,
    menu2: false
  }),

  methods:{
    save() {
      this.finalDate.push(
        this.$refs.datepicker.dates
      )

    }

Error message:

[Vue warn]: Property or method "date" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://v2.vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.

found in

---> <NextMeetingCardComponent>
       <DashboardComponent> at src/views/DashboardComponent.vue
         <VMain>
           <VApp>
             <App> at src/App.vue
               <Root>

Answer №1

Your component contains a randomly generated date:

 <v-card-text v-for="(i,index) in finalDate">
      <v-btn >
        {{i.date}}
      </v-btn>

    </v-card-text>

    <v-divider class="mx-4"></v-divider>

    <v-card-actions>
      <v-spacer />

      <v-col>
        <vs-button>Generate Meeting Link</vs-button>

      </v-col>
      {{date}} <---- CHECK HERE
    </v-card-actions>
  </v-card>
</template>

Is this potentially causing the problem?

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for adjusting the class of elements in neighboring rows of an HTML table with the help of jQuery's nextAll() selector

While attempting to switch classes using the jQuery selector .nextAll(':lt(3)'), I encountered an issue. The class change does not take effect on new rows of HTML tables. It seems like the class change for the next 3 cells is only being applied ...

Converting vue hidden divs to pdf format

After spending some time researching, I discovered a method for exporting the content of divs to pdf while preserving all styles. Contrary to what is stated in this page, I found that html2pdf works effectively compared to vue-html2pdf. By simply referenci ...

Employ jQuery to display a text box with a sliding motion upon hovering the mouse cursor over a specific area

Beginner inquiry about jQuery. Imagine I have a label on my webpage and I am looking to create a sliding effect for an input box when hovering over the label. Can anyone offer tips on utilizing jQuery to make this happen? ...

The attempt to install "expo-cli" with the command "npm install -g expo-cli" was unsuccessful

Encountered an issue while trying to install expo-cli for creating android applications using npm install -g expo-cli. NPM version: 7.19.1 Node version: v15.14.0 Upon running npm install -g expo-cli, the installation failed with the following error mess ...

Hide Transform Controls at Center in Three.js

Is there a way to hide the central controls of the three.js transform controls and only display the xyz arrows in the controller? I have highlighted the sections of the controller that I want to hide in the image below. https://i.sstatic.net/eRz80.png In ...

JQuery transmits null values

I have been troubleshooting my code for what feels like forever, but I just can't seem to find the error... My current project involves experimenting with JQuery and AJAX. I created a simple form with a textarea for submission. The form works perfect ...

Components in React are unable to be accessed

I'm a complete beginner when it comes to React and I'm facing issues with organizing my components into separate files. The error message I encounter is: ERROR in ./src/App.js 5:0-34 Module not found: Error: You attempted to import /components/ ...

Arranging Objects by Date in TypeScript

I came across a code snippet that helps sort objects in an array by date, but I'm having trouble converting it to TypeScript. this.filteredTxs.sort(function(a,b): any{ return new Date(b.date) - new Date(a.date); }); Here's the error mes ...

It is not possible to attach separate links to images in a JavaScript slider

I am struggling with linking individual images in a JavaScript slider for a client's website. The slider is fully functional and works well, but I can't seem to figure out how to link the images properly. When I remove items from <--ul class= ...

What is causing the recurring failure of file input changes to take effect?

Here is the code snippet I'm working with: <input type="file" #fileInput ng2FileSelect [uploader]="uploader" (onFileSelected)="onFileSelected($event)" /> Along with the handler function: public onFileSelected(e: Fi ...

Conceal the div until the animation with a delay of `1s` has finished, then reveal it afterwards

I have incorporated a CSS file to introduce animations on the website I am currently developing. You can find it here: The premise of this CSS file is straightforward - by adding specific class names to div elements, you can animate them as you scroll up ...

A specialized solution designed to avoid loops in references

Is there a method to create a general solution that can prevent circular variables in JavaScript? This solution should be effective for any level of depth or type of circular reference, not limited to the variable itself... So far I've come up with t ...

What is the best way to delete multiple elements from an array using their index values?

When working with an array, the Array.splice method can be used to remove single values. However, if multiple elements need to be removed from an array, such as element 2, 4, and 8 from an array containing 10 elements, using Array.splice(index,1) in a for ...

Maximizing the full potential of a JavaScript menu using WebDriver

I am facing a challenge in clicking a button on a website using WebDriver that utilizes JavaScript to expand a menu and display additional links: <div id="menu"> <div id="security_bt" class="advanced_white_close_button" onclick="open_or_close_sub ...

In a Next.js application directory, how can you retrieve the router.asPath value within a function that utilizes the Next.js navigation feature?

import { useRoute } from "next/navigation" const route = useRoute() const updateData = () => { route.replace(route.asPath); } I attempted using next/router but it was unsuccessful ...

What is the best way to incorporate the compiled output of a JavaScript ES6 repository into another repository

I have two GitHub JavaScript repositories: "chromeextension" and "core". I would like the "chromeextension" repository to consume the build output of the "core" repository (as the "core" repository is written in ES6 and needs to be compiled to ES5 for use ...

Accessing $refs in Vue.js results in an undefined value

Encountering difficulties with the reference, ref, of a tag as it is currently returning null. Excerpts from the code are displayed below: <input-layout v-if="edit" label="Status" class="" ref="statusSubtitle"> ...

Mastering the art of connecting multiple input fields in both parent and child components with the Vue3 composition API

Currently, I am delving into learning Vue 3 with the composition API, but I have encountered some roadblocks. Specifically, I am working on a parent page that looks like this: <template> <q-page class="flex flex-center bg-dark row"> ...

What is the best way to modify part of a URL and refresh the page with the updated changes?

Good evening, everyone. This is my inaugural post on this platform, so I hope I am following the norms correctly. I have scoured various sources, including this site, in search of a solution to a problem I am facing, but I have not come across anything t ...

Is it possible to capture and handle browser-specific errors that occur during an AJAX call? I am having trouble locating and capturing these errors

My goal is to thoroughly test an AJAX call for potential errors by deliberately breaking it in various ways. The error callback in jQuery ajax does not provide detailed information like what the browser logs, which is what I need to capture. For example, C ...