• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

192
Vistas
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"]
almost 3 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Acabo de usar:

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

y funcionó para mí!

almost 3 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 Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda