0

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.

1 Answer 1

1

Did you try vm.selected = 1 for example?

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

Sign up to request clarification or add additional context in comments.

2 Comments

jsfiddle.net/cmal/deLvksm4 It does not work.
@cmal it works... if you open the console you see that vm.$set('selected', '1') is producing an error so the next line does not work. if you remove this line it works

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.