[Vuejs]-Save inital value of input in vuejs

0👍

put in a created (or mounted) lifecycle method and set it there.
like so:

created(){
   this.form.studentId = this.studentId (assuming thats what the prop is called)

0👍

You can use the v-model directive to create two-way data bindings on form input, textarea, and select elements.

  <input v-model="message" placeholder="edit me">

To use v-model with form.studentId[n]:

  1. form should be a data property.
  2. form.studentId should be an array.

Then you can do the following:

 <div v-for='classlist in classlists'>
  <input v-model="form.studentId[classlist.id]">
 </div>



   data() {
     form: {
       studentId: []
     }
  }

Leave a comment