How to drop down programmatically a select menu by clicking on image Vuetify?

妖精的绣舞 提交于 2021-01-29 05:02:08

问题


I have my image property and select in template:

<v-img src='/logos/some.jpg'
        @click='click_select'/>

<v-select :items="currencySelect" 
        ref='select'/>

and in methods, I have method:

click_select(){
  this.$refs.select.onClick;
}

Clicking on image doesn't do anything and no errors logs


回答1:


Just add a callback handler for that event like :

this.$refs.select.onClick((e) => {

  });

Full example

var app = new Vue({
  el: '#app',
  vuetify: new Vuetify(),
  data: {
    currencySelect: ['a', 'b', 'c']
  },

  methods: {
    click_select() {

      this.$refs.select.onClick((e) => {

      });
    }
  }
})
<link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/@mdi/font@5.x/css/materialdesignicons.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.min.css" rel="stylesheet">

<script src="https://cdn.jsdelivr.net/npm/vue@2.x/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.js"></script>


<div id="app">
  <v-app id="inspire">
    <button @click='click_select' class="v-btn-primary">
    select
    </button>

    <v-select :items="currencySelect" ref='select' />
  </v-app>
</div>


来源:https://stackoverflow.com/questions/63124595/how-to-drop-down-programmatically-a-select-menu-by-clicking-on-image-vuetify

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!