El Anonimo
El Anonimo

Reputation: 1870

Allow user input on Vue input prefilled with server data

I have a few text inputs that receive data from a backend API. I also need to allow user to enter his data to the inputs. How do I fix the code below to allow for it?

<input
  type='text'
  class='form-control input--square'
  id='cell'
  placeholder='Женат'
  :value='profile.persAdditionalInfo.family === 1 ? "Married" : "Not married"'
  @input='profile.persAdditionalInfo.family = $event.target.value'
/>

profile.persAdditionalInfo.family receives either 0 or 1.

Upvotes: 0

Views: 35

Answers (1)

Ilya Degtyarenko
Ilya Degtyarenko

Reputation: 1569

Use v-model

data: () => ({
    message: null
})

<input v-model="message" placeholder="отредактируй меня">

Upvotes: 2

Related Questions