1. 程式人生 > >(Vue) Html中select拿不到option的值

(Vue) Html中select拿不到option的值

 問題描述:

在edit.html中,獲取list.html傳來的id,用id查詢資訊然後顯示到edit.html的各個對應的位置中

下拉框選擇一個數據,再點儲存,提示 “xx不能為空”、

下拉框選擇一個數據,顯示正確,但是換到其他input中,只要輸入,下拉框就變回原來的值

 Html 程式碼:

<select style="width:100%" v-model="cmdMaterialStorage.repertoryId" 
            isvalid="yes" required checkexpession='NotNull'>
    <option value="0" selected="selected">請選擇</option>
	<option v-for="option in repertoryList" v-bind:value="option.rertoryId">
    <!--通過迴圈,取出id和name-->
        {{ option.repertoryName }}
  	</option>
</select>

解決方案:

檢視是否字元寫錯或者沒有對應,比如我的下拉框的repertoryId拿不到,原因是因為實體類中寫的是 id 

<select style="width:100%" v-model="cmdMaterialStorage.repertoryId" 
            isvalid="yes" required checkexpession='NotNull'>
    <option value="0" selected="selected">請選擇</option>
	<option v-for="option in repertoryList" v-bind:value="option.id">
    <!--通過迴圈,取出id和name-->
        {{ option.repertoryName }}
  	</option>
</select>