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

155
Views
vue, haga coincidir la cadena en la matriz sin ID y elimínela si coincide

Tengo una matriz simple de cadenas, y estoy llamando a una función con acciones desplegables que enviarán una cadena, y si coincide con una en la matriz, quiero eliminarla de la matriz, pero no estoy seguro de cómo

He visto cómo podría hacer esto con empalme, pero no tengo ID en esta matriz, son solo cadenas. Entonces, literalmente, necesito hacer coincidir la cadena y eliminarla en función de esa coincidencia de cadena

¿Cómo puedo simplemente hacer coincidir y eliminar una cadena de la matriz?

aquí está mi código:

 new Vue({ el: "#app", props: { }, data: { tierArray:['one', 'two', 'three'], }, methods: { removeTierSelection(value){ console.log('this is what we are removing'); console.log(value.name); //this prints just the string such as "one" or "two", but without the quotes }, } })
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Puedes lograrlo haciendo esto:

 const removeIndex = this.tierArray.findIndex(tier => tier === value.name) if (removeIndex === -1) return // means item not found this.tierArray.splice(removeIndex, 1)
about 4 years ago · Juan Pablo Isaza Report

0

Otro enfoque simple sería

 this.tierArray = [...this.tierArray.filter(tier => tier !== value.name)];
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!