[Vuejs]-Vue selected option

0👍

You need to set the value of selected in some manner. One way is, as Sphinx pointed out in their comment, is to use a mounted() lifecycle hook:

const app = new Vue({
  el: "#app",
  mounted() {
    this.selected = "used";
  },
  data() {
    return {
      selected: "",
      item: "new"
    };
  }
});
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.min.js"></script>

<div id="app">
  <select id="application-status" class="custom-select" v-model="selected">
    <option :value="null" disabled>Status</option>
    <option :value="'new'" v-bind:selected="item.new != null">New</option>
    <option :value="'used'" v-bind:selected="item.used != null">Used</option>
  </select>
</div>

Leave a comment