2017-02-22 85 views
2

對不起,新手問題。 但是我怎麼能從選擇框中獲得所選元素的索引並運行一個函數。我的代碼如下,不會觸發switchView()函數。如何獲取與vue.js選定的選項索引

<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)"<option><select>,由於@Phil

我需要的指數,因爲我有幾個計算項目。而且我需要根據用戶對項目的選擇來改變視圖。

+3

該事件的''