What could be causing the props to appear empty in a Child component within a Quasar framework and Vue 3 application?

I am facing an issue while passing props to a Child component table in my Quasar Vue3 app. The content is not being rendered, and I can't figure out why. Strangely, the console is clear of any errors. In the parent component, I am creating an object with keys and values, and then trying to pass it as a prop to the child component for rendering. Additionally, I have a button in the parent component that toggles a modal window.

    // Child component

    const props = defineProps({
        airCraft: {
          required: true
        }
      })
      const rows = [props.airCraft]
      
      <template>
      <q-dialog >
          <q-card>
            <q-card-section>
              <q-table
                title="name"
                :rows="rows"
                :columns="columns"
                row-key="name"
                :hide-bottom="rows.length > 0"
                flat bordered
                >
                <template v-slot:body="props">
                  <q-tr :props="props">
                    <q-td key="id" :props="props">
                      {{ props.row.id }}
                    </q-td>
                <template>
              <q-table>
          <q-card-section>
        <q-card>
      <q-dialog >        
      <template>
      
      // Parent component
     <script>
     let airCraft = {
      id: '1',
      name: 'name'
     }
     <script setup>
import {ref} from 'vue' 
let fixed = ref(true)
     <template>
        <ModalAircraft v-model="fixed" :airCraft="airCraft" @click='fixed = true'/>
      <template>

Answer №1

It seems like the issue arises from not activating your q-dialog. To resolve this, you need to make changes in your ModalAircraft component as shown below:

<template>
  <div>
    <q-btn label="Click" @click="modal = true" />
    <q-dialog v-model="modal">
      <q-card>
        <q-card-section>
          <q-table
            title="name"
            :rows="rows"
            :columns="columns"
            row-key="name"
            :hide-bottom="rows.length > 0"
            flat
            bordered
          >
            <template v-slot:body="props">
              <q-tr :props="props">
                <q-td key="id" :props="props">
                  {{ props.row.id }}
                </q-td>
              </q-tr>
            </template>
          </q-table>
        </q-card-section>
      </q-card>
    </q-dialog>
  </div>
</template>

<script setup>
import { ref } from 'vue';

const props = defineProps({
  airCraft: {
    required: true,
  },
});

const rows = [props.airCraft];

const modal = ref(false);
</script>

I have added a q-btn to toggle the value of modal to true upon being clicked. Then, I bound the modal variable to the q-dialog. This will display a button once the component is rendered. Upon clicking the button, a dialog box will appear showing your table data.

You can view the updated code here: https://stackblitz.com/edit/stackblitz-starters-icrnbz

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

When working with ReactJS and NextJS applications, the variables declared in the .env file may sometimes be received as undefined

In my .env.local file, the following variable is defined: REACT_APP_API_PATH=http://localhost:3600/ The .env.local file can be found at the root level of the project directory. Here is how I am attempting to utilize this variable: console.log('node ...

Express Js EJS Layouts encountered an issue: No default engine was specified and no file extension was included

Hey there! I'm currently experimenting with implementing Express EJS Layouts in my application. However, as soon as I try to include app.use(expressEjsLayouts), an error is being thrown. The application functions perfectly fine without it, but I reall ...

Is the Await keyword failing to properly pause execution until the promise has been fulfilled?

I'm currently working on manipulating a variable within an async function, and I've noticed that the variable is being returned before the completion of the data.map function below. Even though I have the await keyword in place to pause the code ...

VueRouter child route with trailing slash after default

VueRouter automatically includes a trailing slash before the child route's path. Consider this example of a route configuration: const routes = [ path: '/home', components: { default: HomeBase }, children: [ ...

What method can be employed to eliminate choice selection lacking any value?

Currently, I am encountering difficulties in my attempt to remove or hide the first option value from a ransack code. Would you be able to assist me in addressing this concern? Here is the HTML CODE that I am working with: <select id="q_c_0_a_0_name" ...

The definitive method for resolving synchronization problems between Protractor and Angular

The Issue at Hand: We recently encountered a common error while attempting to open a specific page in our application during a Protractor end-to-end test: Error: We timed out waiting for asynchronous Angular tasks to complete after 50 seconds. This cou ...

Is there a way to determine if a value exists within an array of objects?

Is it possible to determine if a specific value is present in an array of objects? I've tried a method, but it always returns false. What would be the most effective way to solve this issue? My approach: var dog_database = [ {"dog_name": "Joey" ...

Creating a tooltip with a left arrow and a bordered design

I am looking to create a tooltip that displays its content after clicking on the tooltip tip icon. Currently, it only works on hover, but I want it to be clickable and mobile responsive. Desktop design should resemble: https://i.sstatic.net/FQPyt.png Mob ...

Why do two date type variables have identical content?

I'm trying to grasp why the value of d1 changes in each alert(). Any insights would be greatly appreciated. Thanks! <script> d1 = new Date("01/01/2015"); d2 = d1; alert(d1); d2.setDate(d2.getDate()+10); alert(d1); </script> ...

Adjust the variable value if the "for" loop encounters an error

In my situation, I have a spreadsheet that contains a script responsible for checking another linked spreadsheet for a customer's name and then returning the associated code. Everything works smoothly when the customer name is found in the "CustomerCo ...

Trouble encountered with Algolia Vue InstantSearch: Problem arising from the 'searchParameters' setting

I'm currently facing a challenge with setting up Algolia using Vue InstantSearch. Specifically, I am trying to utilize the <ais-configure> widget to define search parameters, but I keep encountering the following issue: Error: The 'search ...

To utilize the span and input text increment functionality, simply use the required input type number and hold either the up or down arrow

Is it possible to increment the value of an input type number by 1 when holding down on a mobile device? <input type="text" id="number" value="1"> <span id="upSpan"> Up </span> $('#upSpan').on('touchstart', function ...

When an HTML element is deleted, its events are not being removed as expected

I currently have events bound in my backbone view. sampleView = Backbone.View.extend({ events: { "click .sum": "sumButtonFunc", "click .diff": "diffButtonFunc" } sumButtonFunc: function(){ console.log("sum called") ...

Programmatically configure filter settings for vue-good-table

Is it possible to dynamically change the displayed value in UI filter elements (such as input fields and dropdowns) within vue-good-table? For instance, if I were to execute the following code: this.$set(this.table.columnsFilters, 'name', ' ...

Can you provide instructions for generating a simple menu bar with options utilizing webgl/three.js?

I find the documentation for the three.js 3-D viewer difficult to understand as a beginner. I am curious about the fundamental steps involved in creating a menu bar or selector with options for a 3-D viewer using three.js / WebGL. Additionally, I am inter ...

Tips for utilizing createTextNode in JSDOM

When attempting to create a UI test for an HTML element using Jasmine and jsdom, I encountered an issue. Within my component, I utilized the createTextNode function to populate the content of the DOM element. Unfortunately, during testing, the document.c ...

Exploring the world of functional programming within nested arrays

I have been shifting towards functional programming over imperative programming recently. Imagine I have a nested array data structure and my goal is to update the values of the innermost arrays. What approach would be most effective? Here is the imperat ...

What is the best way to transmit error messages from the server to the client?

I am currently working on my express server and I have a query regarding how to efficiently communicate error messages to the client side. My goal is to display the error message both on the client console as well as on the server console, but I am uncerta ...

Passing a variable to a template in Node.js and express with hbs is causing an unexpected identifier error

I’m working on a Node.js Express app, and I’m trying to pass a variable when rendering my index.hbs file, like this: <!DOCTYPE html> <html> <body> Hello. <a href="/auth/facebook">Login with Facebook</a> {{ ...

Checkbox enabled Bootstrap image

I am encountering a minor issue where I am attempting to incorporate a simple image that can be toggled on and off by clicking on it. After coming across some bootstrap code online, I decided to test it in my project. Unfortunately, the code does not seem ...