Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

117
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda