Home > Net >  vue changing selected option by js, using v-model
vue changing selected option by js, using v-model

Time:12-30

How to control the selected value in a v-modeled select tag in vue.js?

I made a jsFiddle demo, this demo does not work, and expressed my question:

vm.$set('selected', '1') // not work!
vm.select('1') // not work!

I want to change selected to make the option to be changed when the js codes was executed.

CodePudding user response:

Did you try vm.selected = 1 for example?

https://vuejs.org/v2/guide/instance.html#Data-and-Methods

  • Related