下の選択ボックスで最初のオプションを選択します。私はthis.el.selected = trueを試しました。 およびv-inの選択ボックスの最初のオプションを選択
if (newValue == 0) return "selected";
いずれも機能しません。
<table class="table table-striped">
<tr v-for="result in results">
<select v-model='products[$index].startTime' class="form-control input">
<option v-for="(timeIndex, time) in result.start_times" v-selected="timeIndex" >@{{ time.start_time }}[email protected]{{ timeIndex }}</option>
</select>
</tr>
</table>
Vue.directive('selected', {
bind: function() {
},
update: function (newValue, oldValue) {
if(newValue==0)
{
this.el.selected = true;
}
return "";
},
unbind: function() {
}
})
どうすればこの問題を解決できますか?私は間違って何をしていますか?より良い方法がありますか?
:あなたに=「$インデックス=== 0」を選択し、V-用ループ、あなたは彼のコードに示すディレクティブ – vbranden