Skip to content
Advertisement

Hidden value from Input not working with VUE JS

Hidden value from vue not working.

The v-model of the one input its not working.

JavaScript

v-model="newcomment.post_id" value is null.

How to fix this?

Advertisement

Answer

I will assume that you using using vue 2, and that what u asking basically boils down to default value for input.

  1. Interpolation inside attributes has been removed in vuejs 2. so value="@{{items.id}}" is not a legal statement.

  2. v-model inherently passing :value already. so passing it again with value="@{{items.id}}" might cause unexpected behaviors. this aspect of v-model mechanics of v-model is documented in vue.js documentation.

    so, as stated, v-model is just syntactic sugar for:

<input v-bind:value="something" v-on:input="something =$event.target.value">

Please see the pattern that you should use to achieve default value for input:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement