V-model in vue, rendering problem

there is a business scenario, that is, I have a form form fields that are bidirectional data bound through form data objects, responsible for adding and editing items

[scene] Open the edit button, get the value from the interface, assign the content to the page, and open the new button. According to reason, you need to empty the form

. The

problem arises, that is, when I open the form, I directly assign an empty object to the two-way bound object of the form, and the page is empty, but I have a doubt that the field bound to the page through v-model, why not report an error when I assign the form object to an empty object?

 <el-form label-width="40px"><el-form-item label="" prop="">
      <el-input size="small" v-model="articleForm.basicTitle"></el-input></el-form-item>
        <el-form-item label="" prop="">
                 <el-input size="small" placeholder="" v-model="articleForm.articleAuthor" >
                    
                 </el-input>
              </el-form-item>
              <el-form-item label="" prop="">
                 <el-input size="small" type="textarea" v-model="articleForm.basicDescription">
                 </el-input>
              </el-form-item>
           </el-form>

data: {

 articleForm: {
        basicTitle: "", //
        articleAuthor: "", //
        basicDescription: "", //
        articleContent: "", //
  },
  mainArticle: {
    basicPic: "", //
    basicTitle: "", //
  },

}
open:function (material) {

if(material && material.newsId>0){
       //     
 }else{
   // 
    this.articleForm = {}
    this.mainArticle = {}
 }

}


sort out the problem with this binding.

  1. v-model is a two-way binding. When you set the object to empty, v-model is equivalent to assigning a value to the bound object property, so it will not report an error
  2. and then the mechanism of vue is that watch does not change with the newly added attributes, so you need to use the $set method to set

in general, the form cleanup in my project is done during the watch pop-up window:

:

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b35a0c-2bfc1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b35a0c-2bfc1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?