Unexpected mutation of “xxxx“ prop

Insert image description here

reason

It's because the child modified the parent's data, so this error was reported when eslint was executed.

Fix 1

If it is a component such as a pop-up window, it can be modified according to the function. For example, the dialog of element ui I use can be changed to this

Insert image description here

Use model-value instead
Insert image description here

Fix 2

Create a new subcomponent variable, and then use watch to synchronize parent-child and variable data.

Fix 3

If you are using the input component, you need to add an @update method, and that's it.

 <a-modal :visible="visible"  @update:visible="updateVisible" >
 
  const updateVisible = (e) => {
    
    
    emits('update:visible', e);
  };
  
  const emits = defineEmits<{
    
    
    (e: 'handleOk', val: any): void;
    (e: 'update:visible', val): void;
  }>();

Guess you like

Origin blog.csdn.net/weixin_40639095/article/details/132597441