2
I have a form with some inputs that has v-model and others with v-bind:value receiving an initial value for the 'date'. Every time I type something into a v-model field it resets the value of the fields with v-bind:value to the initial value.
The error only happens in version 2.x of vuejs.
jsfiddle with an example: https://jsfiddle.net/ypeacuth/
new Vue({
el: '#app',
data: {
nome: 'Ted',
sobrenome: ''
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<input type="text" id="nome" name="nome" v-model="nome">
<input type="text" id="sobrenome" name="sobrenome" :value="sobrenome">
</div>
The @rnd_rss explanation is correct... When you do
<input :value="sobrenome">
you’re saying the propertyvalue
will always be what’s insidedata.sobrenome
.. And howdata.sobrenome
is a string empty and never modified, Vue’s behavior is to make thevalue
one string empty whenever render component.– fernandosavio