Dynamic v-model. Hmm.....
-
I was playing around with slots and trying to make some silly system for a survey and I’m almost there.
http://jsfiddle.net/smolinari/3zLp4s6n/
Problem is, the dynamic setting of the v-model isn’t working. I’ve looked everywhere as to how to set this, but could’t find a fitting example. Is this not possible?
Scott
-
I think the reply here is telling me, ternaries in v-model won’t work. Ok. trying a different method…
https://github.com/vuejs/vue/issues/8390
Scott
-
Ok. This is the solution. I guess. Anyone with a better idea, please let me know.
http://jsfiddle.net/smolinari/9cdrswov/
Scott
-
You can bind
value
and handle theinput
event
https://vuejs.org/v2/guide/components.html#Using-v-model-on-Components -
@morlz - thanks but how does that help with the ternary operation not working in v-model? I’m not getting the connection.
Scott
-
@s-molinari In the getter, you can choose from where you need to get the value, and in the “input” handler, choose where you want to assign it.
-
@morlz - can you possibly show what you mean in the first fiddle above?
Scott