如何使用 vue.js 获取所选选项的索引 [英] How to get index of selected option with vue.js

查看:77
本文介绍了如何使用 vue.js 获取所选选项的索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

抱歉新手问题.但是如何从选择框中获取所选元素的索引并运行函数.我下面的代码不会触发 switchView() 函数.

Sorry for newbie question. But how can i get an index of selected element from selectbox and run a function. My code below doesn't trigger switchView() function.

<select id="selectbox" @change="switchView(index)">
  <option [v-for="(item, index) in items" v-bind:value="item.title"]>
    {{ item.title }}
  </option>
</select>

任何帮助将不胜感激.

@change="switchView(index)" 移动到

发送“验证码”获取 | 15天全站免登陆