Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

131
Views
Pasar un valor de props a una función externa en Vuejs 3

Tengo una página que muestra los detalles de un usuario y necesito mostrar las facturas que pertenecen a ese usuario.

 <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>

Tengo un archivo JS que llama a la API para obtener los datos, importados en la plantilla de factura. Estoy tratando de obtener el ID de proveedor en ese archivo JS para que pueda pasarse como un parámetro.

Mi plantilla de factura se parece a:

 <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>

Mi useInvoiceList.js se ve así:

 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, } }

¿Cómo obtendría la identificación del proveedor en el método fetchInvoices?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Una forma es establecer el valor de la variable en la tienda y usarlo directamente en su archivo js, ya que ya está importando la tienda en ella. De otra manera, puede pasar parámetros a fetchInvoices (props.vendorId).

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!