0

My code is simple, I have an array with multiple entries inside of it. I would like to cycle through that array, and create a single drop down box with all the array values listed as 'select' options.

However, multiple drop down boxes are being created instead of just one, I don't know why. Each drop down box does have the correct {{ group }} name, so it is pulling the data properly from what I can see, it just needs to be in one select list.

HTML:

<select class="groupContainer"  v-for="(group, id) in groupList" :key="group.id">
  <option v-bind:value="groupList[id]" class="groupValue"> {{ group }} </option>
</select>

Vue:

export default {
  name: 'AddPaste',
  data(){
    return{
      title: null,
      content: null,
      feedback: null,
      slug: null,
      groupList: []
    }

  },

1 Answer 1

1

v-for should be in option tag, not select

<select class="groupContainer"  >
  <option v-for="(group, id) in groupList" :key="id"
    v-bind:value="group" class="groupValue"> 
    {{ group }} 
  </option>
</select>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.