如何通过单击图像 Vuetify 以编程方式下拉选择菜单?

我有我的图像属性并在模板中选择:


<v-img src='/logos/some.jpg'

        @click='click_select'/>


<v-select :items="currencySelect" 

        ref='select'/>

在方法中,我有方法:


click_select(){

  this.$refs.select.onClick;

}

单击图像不执行任何操作,也没有错误日志


撒科打诨
浏览 78回答 1
1回答

函数式编程

只需为该事件添加一个回调处理程序,例如:this.$refs.select.onClick((e) => {&nbsp; });完整示例var app = new Vue({&nbsp; el: '#app',&nbsp; vuetify: new Vuetify(),&nbsp; data: {&nbsp; &nbsp; currencySelect: ['a', 'b', 'c']&nbsp; },&nbsp; methods: {&nbsp; &nbsp; click_select() {&nbsp; &nbsp; &nbsp; this.$refs.select.onClick((e) => {&nbsp; &nbsp; &nbsp; });&nbsp; &nbsp; }&nbsp; }})<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">&nbsp; <v-app id="inspire">&nbsp; &nbsp; <button @click='click_select' class="v-btn-primary">&nbsp; &nbsp; select&nbsp; &nbsp; </button>&nbsp; &nbsp; <v-select :items="currencySelect" ref='select' />&nbsp; </v-app></div>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript