[Vuejs]-Vue selected first option with v-model

1๐Ÿ‘

โœ…

Set your docType in data, to the value you want to be the default.

data(){
  return {
    docType: "paragon"
  }
}

Example.

console.clear()

new Vue({
  el: ".form-group",
  data(){
    return {
      docType: "paragon"
    }
  }
})
<script src="https://unpkg.com/vue@2.4.2"></script>
<div class="form-group">
  <label class="control-label" for="docType">Type of document</label>
  <select class="form-control" id='docType' name="docType" v-model="docType" :disabled="noDocChoose == true">
                    <option value="paragon">Document1</option>
                    <option value="complaint">Document2</option>
                </select>
</div>
๐Ÿ‘คBert

2๐Ÿ‘

Are you asking if you can make the select have an empty default value? In that case, you would have to add another option that has a blank value. For example:

    <select class="form-control" id='docType' name="docType" v-model="docType">
      <option value="">- please select -</option>
      <option value="paragon">Document1</option>
      <option value="complaint">Document2</option>
    </select>

The value of the option that matches the docType model would be selected.

๐Ÿ‘คandrunix

Leave a comment