Skip to content

2.0 example for Value Binding with Select Options seems broken #404

@kili-ilo

Description

@kili-ilo

I'm learning Vue by working through the 2.0 guide, so this is likely my mistake.

When I try to implement the Form Input Bindings - Value Bindings - Select Options example as below, I get vm.selected === undefined whenever I select any option (also, the first option, 123, always appears "checked" in the dropdown).

I'm using Vue.js v2.0.0-rc.5

My code is here: https://github.com/jvanbrug/vue-guide-examples/tree/master/08_Form_Input_Bindings/02_Value_Bindings

The live demo of that code is here: https://jvanbrug.github.io/vue-guide-examples/08_Form_Input_Bindings/02_Value_Bindings/index.html

Thanks for Vue, Vuejs.org, and any help with this! 😃


index.html

<body>
  <div class="content">

    ...

    <div id="example-select" class="demo">
      <select v-model="selected">
        <option v-bind:value="{ number: 123 }">123</option>
        <option v-bind:value="{ number: 456 }">456</option>
        <option v-bind:value="{ number: 789 }">789</option>
      </select>
      <div>
        Selected type: {{ typeof selected }}
      </div>
      <div>
        Selected number: {{ typeof selected === 'object' ? selected.number : 'N/A' }}
      </div>
    </div>

    ...

  </div>
  <script src="../../vue.js"></script>
  <script src="./main.js"></script>
</body>

main.js

...

var vm = new Vue({
  el: '#example-select',
  data: {
    selected: undefined
  }
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions