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

150
Views
Cómo abrir un menú desplegable de selección al pasar el mouse usando Bootstrap Vue

Necesito una forma de activar <select> o <b-form-select> y mostrar la lista de opciones desplegables al pasar el mouse por encima. Sin utilizar JQuery ni ningún complemento externo que no sea Vue.js.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Según tengo entendido, desea mostrar/ocultar <b-form-select> en el evento mouseover y mouseleave . En caso afirmativo, tengo algunas sugerencias :

  • Use un div como contenedor que activará los eventos mouseover y mouseleave . Podemos activar directamente los eventos del mouse agregando el native en sí mismo, pero una vez que se oculte, no habrá forma de volver a colocar el menú desplegable en el mouseover.
  • Simplemente puede mostrar/ocultar el menú desplegable a través de la directiva v-show . Podemos establecer fácilmente el valor de los eventos de nuestro mouse.

Demostración de trabajo:

 new Vue({ el: '#app', data() { return { selected: null, isVisible: true, options: [ { value: null, text: 'Please select an option' }, { value: 'a', text: 'This is First option' }, { value: 'b', text: 'Selected Option' }, { value: { C: '3PO' }, text: 'This is an option with object value' }, { value: 'd', text: 'This one is disabled', disabled: true } ] } }, methods: { onOver() { this.isVisible = true; }, onLeave() { this.isVisible = false; } } })
 .wrapper-div { height: 20px; }
 <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script> <script src="https://unpkg.com/bootstrap-vue@2.22.0/dist/bootstrap-vue.js"></script> <link rel="stylesheet" href="https://unpkg.com/bootstrap-vue@2.22.0/dist/bootstrap-vue.css"/> <div id="app"> <div class="wrapper-div" @mouseover="onOver" @mouseleave="onLeave"> <b-form-select v-model="selected" :options="options" v-show="isVisible"> </b-form-select> </div> </div>

about 4 years ago · Juan Pablo Isaza Report

0

El efecto de esta solución es similar a abrir el select haciendo clic en él (aunque, no es lo mismo...)

 <template> <select ref="mySelect" @mouseenter="hover(true)" @mouseleave="hover(false)" :size="size"> <option value="1">option 1</option> <option value="2">option 2</option> <option value="3">option 3</option> </select> </template> <script> import {ref} from 'vue'; export default { name: "Test", setup(){ const mySelect = ref(); const size = ref('0'); return {mySelect, size} }, methods: { hover(val) { this.size = val ? this.mySelect.length.toFixed(0) : '0'; } } } </script>
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!