Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

116
Vistas
Passing a props value to an external function in Vuejs 3

I have a page showing details of a User and need to display the invoices belonging to that user.

<template>
    <div>
        <div>
            // Child component one .....
        </div>
        <div>
            // Child component two .....
        </div>

        <div>
            // Invoice component one .....
            <invoice-list :vendor-id="vendorData.id"/>
        </div>
    </div>
</template>

I have a JS file that calls the API to fetch the data, imported in the invoice template. I am trying to get the vendorId in that JS file so that it can be passed as a param.

My invoice template looks like:

<template>
    <div class="wrapper">
        <!-- Table Container grid -->
        ---------
        ---------
        ---------
    </div>
</template>

<script>
import { onUnmounted } from '@vue/composition-api'
import store from '@/store'
import useInvoicesList from './useInvoiceList'
import invoiceStoreModule from '../invoiceStoreModule'


export default {
  props: {
    vendorId: {
      type: String,
      required: false,
    },
  },
  setup(props) {
    
    const {
      fetchInvoices,
      refetchData,
    } = useInvoicesList()

    return {
      fetchInvoices,
      refetchData,
    }
  },
}
</script>

My useInvoiceList.js looks like:

import { ref, watch, computed } from '@vue/composition-api'
import store from '@/store'

export default function useInvoicesList() {

  const refInvoiceListTable = ref(null)

  const fetchInvoices = (ctx, callback) => {
    store
      .dispatch('app-invoice/fetchInvoices', {
        q: searchQuery.value,
        **/*This is where I need the vendor ID*/**
      })
      .then(response => {
       
      })
      .catch(() => {
        
      })
  }

  return {
    fetchInvoices,
    refInvoiceListTable,
    refetchData,
  }
}

How would I get the vendor ID in the fetchInvoices method?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

One way is to set the variable value in the store and use it directly in your js file as you are already importing store in it another way you can pass parameters to fetchInvoices(props.vendorId).

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda