问题
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