Note: The vue component reuses the value, and the second click data does not change

Problems encountered:
The data exists when the first click is clicked to edit, but the data does not change when the second click is clicked to edit
Insert picture description here

Reason: The
original words of the vue official website: Just a reminder, when using routing parameters, such as navigating from /user/foo to /user/bar, the original component instance will be reused. Because both routes render the same component, reuse is more efficient than destroying and recreating. However, this also means that the component's lifecycle hooks will no longer be called.

Solution:
Use watch to monitor parameters

watch: {
    
    
     dialogObj:{
    
    
         handler(newval, old) {
    
    
                this.form = newval
         },
      },
},

newval is the value passed in, and old is the old value.
At this point, as long as newval is assigned to the form object, it will be automatically rendered

Guess you like

Origin blog.csdn.net/weixin_43236062/article/details/106419500