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

240
Views
función de disparo una vez cuando se crea el elemento (pasar a métodos) / VueJS

Estoy trabajando con BootstrapVue . Primero quiero explicar mi código en breve:

Tengo un v-for con entradas, que puedo crear tantas veces como quiera con un b-button -> addElement . O puedo seleccionar un item de mi b-dropdown : allí estoy verificando la longitud de mi selección y presiono la cantidad de mi arrayLength como mis entradas.

-> por ejemplo, matriz seleccionada = ['1111', '2222', '3333'] -> arrayLength = 3 -> 3 entradas

Ahora necesito que una función se active automáticamente ( marked as ??? ) cuando sucedió exactamente este caso de que estoy seleccionando algo de mi menú desplegable, por ejemplo, es mi arrayLength = 3 , debe activarse 3 veces con la id, indexParent and indexChild . ¿Cómo puedo solucionar eso?

Necesito estos parameters mencionados anteriormente en mis métodos.

¡Gracias por adelantado!

 <div v-for="(id, indexChild) in inputs" :key="indexChild"> <b-dropdown text="Select" right variant="success"> <b-dropdown-item v-for="(item, indexDropdown) in json" :key="indexDropdown" @click="trySomething(item.Number)">{{item.Name}}</b-dropdown-item> </b-dropdown> <b-button vb-toggle="'newElement'+indexParent+indexChild">Element {{indexChild + 1}}></b-button> <b-collapse :id="'newElement'+indexParent+indexChild" <div ???="getValues(id, indexParent, indexChild)"> <!-- how can I fire this when created? --> <!-- Do some more code --> </div> </b-collapse> </div> <!-- create new "item"-elements --> <div> <b-button @click="addElement()">Add element</b-button> </div>
 methods: { addProduct() { this.inputs.push({}) }, trySomething(itemValue) { var array = []; const products = this.otherJSON.find((i) => i.Number === itemValue); for (let key in products.ID) { array.push(products.ID[key]); } this.getLengthArray = array.length; this.inputs.splice(0) //at first I need to delete all to push exact inputs based on arrayLength for (let i = 0; i < this.getLengthArray; i++) { this.inputs.push({}); } }, getValues(id, indexParent, indexChild) { //Here I need the parameters id, indexParent, indexChild } }, data() { return { inputs: [{}], } }, props: ["indexParent"]
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Acabo de usar:

 <div v-if="getValues(id, indexParent, indexChild)" v-once></div>

y funcionó para mí!

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!