How do assign another variable whose value is changed, the original value remains unchanged

There is a project in question is a drop-down selection form, change its value when the form below emergence of a new specific form to fill in, so choose a value when the form below to fill in, but this time to change selected value, below the form will become the initial value, the initial time is created in the form below to dynamically change the saved value, since created only runs once when rendering dom

  <el-form ref="form" :model="form" label-width="80px">
      <El-form-item label = "active area">
        <El-select v-model = "form.region" placeholder = "Choose activity area" @ change = "changeData">
          <el-option label="上海" value="shanghai"></el-option>
          <el-option label="北京" value="beijing"></el-option>
          <el-option label="山东" value="shanghai"></el-option>
          <el-option label="内蒙古" value="beijing"></el-option>
        </el-select>
      </el-form-item>
      <! - data expansion below the upper side according to a change to the initial value ->
      <El-form-item label = "Event Name">
        <el-input v-model="form.name"></el-input>
      </el-form-item>
      <El-form-item label = "a person aged">
        <el-input v-model="form.age"></el-input>
      </el-form-item>
      <El-form-item label = "Activity Address">
        <el-input v-model="form.address"></el-input>
      </el-form-item>
      <El-form-item label = "contact person">
        <el-input v-model="form.phone"></el-input>
      </el-form-item>
    </el-form>


 data() {
    return {
      form: {
        region: "",
        name: "party",
        age: "",
        address: "",
        phone: ""
      },
      textData: {}
    };
  },
  methods: {
   // previously filled form of the original data becomes data when changing the value 
    changeData () {
       the this .form the JSON.parse = ( the this .textData)
    }
  },
  created() {
    this.textData =JSON.stringify(this.form) ;
  },

The main thing is to save under a JSON.parse (JSON.stringify (this.form)), if the direct assignment, then a value change, the other is out of print after changing the value, and the principle is related to the heap and stack, so to I want changes to the original value of the need to retain the original value, in this way

  

Guess you like

Origin www.cnblogs.com/yanyanliu/p/12043726.html