Vue has multiple input boxes that initially bring information. How can you collect the modified initial information after modifying the initial information, and not collect the unmodified initial information?

problem description

For a page made by

, the initialization of the page has a set of input boxes that will bring the initial information. For example, as seen in the
following code, if I only modify the company acronym, then I want to record the modified items. There is an object, but the other unchanged items are not recorded

.

related codes

<el-form-item label="" prop="name">
   <el-input size="medium" v-model="companyForm.name"></el-input>
</el-form-item>

<el-form-item label="">
   <el-input size="medium" v-model="companyForm.reduceName"></el-input>
</el-form-item>

<el-form-item label="" prop="phone">
    <el-input type="text" size="medium" v-model="companyForm.phone"></el-input>
    <span class="stuff-hering">(025-88888888)</span>
</el-form-item>

I tried watch,. I don"t know if it is wrong or unsuccessful. Please give me some ideas.

Apr.02,2021

directly watch companyForm should not work. You should traverse key

of companyForm .
 watch: {
        companyForm: function(val, oldVal) {
            // 
        }
    }

or you can listen to the change event

of input .

it is possible for wacth to listen to the values in every input.
Let me suggest a stupid idea

 


  
      input
Menu