L
L
lem_prod2017-04-13 23:10:51
JavaScript
lem_prod, 2017-04-13 23:10:51

How to properly bind values ​​to a Vue component?

I ’m dealing with Vue.js
, I wrote this thing
https://jsfiddle.net/veuop8m7/1/
2 lists, one in the root element, and it has v-model
another directly through the component, and it’s written :valuefor @change
clarity, in the component I do {{value}}what I would like to see that the binding works
after 2 seconds, I change the list on which it renders <option>
after 2 more, I change it, value
help me figure out why the elements behave differently?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
lega, 2017-04-14
@lega

It's simple, the :value directive is used in the component - it does not track option changes as v-model does.
I will add: when changing the option, the browser automatically corrects the value of select.value, :value does not take this into account.

E
Evgeny Kulakov, 2017-04-14
@kulakoff Vue.js

Alternatively: https://jsfiddle.net/kulakoff/ywk9ova8/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question