0️⃣

selectで追加値(デフォルト値)が必要なときにフロントエンドで処理する方法

デフォルト値のようにCSS処理もしました。
const isSelectedClass = computed(() => { return exampleState.value.cashback_id === 0 ? 'text-gray-400' : 'black'; }); </script> <template> <select v-model="exampleState.id" :class="isSelectedClass" > <option :value="0">未選択</option> <option v-for="{ id, name } in apiOption" :key="id" :value="id" > {{ name }} </option> </select> </template>