Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

177
Vistas
Drop down selection to match one item in array VueJS, JS

I am trying to get an exact match for my drop-down selections. So in this example, if I select 'apple' it runs the query okay but it also returns results for 'pineapple'too. How do I get an exact match only?

I have another function in my app that returns the uniqfruit data.

The drop-down

<select id="fruitselect"
                v-model="fruit"
                class="form-control"
                @change="fruitonChange($event)"
                :disabled="selectDisabledfruit"
              >
                <option disabled value="">Select fruit</option>
                <option v-for="fruit in uniqfruit" :key="fruit" :value="fruit">
                  {{ fruit }}
                </option>
              </select>

The VueJS function

fruitonChange: function (e) {
      var id = e.target.value;
      var fruit = e.target.options[e.target.options.selectedIndex].text;

      if (id === uniqfruit) {
        this.runquery();
      } else {
        e = "!showall";
      }
      console.log("id ", id);

      console.log("fruit ", this.fruit);
      console.log("uniqfruit ", this.uniquefruit);
    },

Console results

id  apple
fruit  apple
uniqfruit  Proxy {0: 'apple', 1: 'banana', 2: 'pineapple', 3: 'kiwi'}
about 4 years ago · Santiago Trujillo
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 Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda