Majeed
98
0
Vue

How to set pre-selected value in vue js dropdownlist.

Posted 3 months ago by Majeed

I want to set selected value on dropdownlist in Vue. Here is my code:

  <label>Role</label>
          <select multiple v-model="mutableRoles" class="form-control">
             <option v-for="(role,index) in roles"  v-bind:value="index">{{role.name}}</option>
           </select>

 props:{
      userdata:{
        type:[Array,Object],
        required:true,
      },
      roles:{
        type:[Array,Object],
        required:true,
      },
    },
    data(){
      return{
       mutableRoles:[],
    
      }
    },

i want to pre-selected roles value based on userdata value..

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.