Vue reuse component emit problem

reuse a common child component in the parent component, and the child component will have user actions that trigger part of the data of the emit to be received and processed by the parent component. In normal logic, this is no problem. I wrote a simple demo like this, but the custom events of the common child components introduced in different places in the project will be solved in the same function. (the project code is too long to post, which god guide can talk about the train of thought.)
at 18:17:59 on September 17, 2018
update the problem description and test it again in depth. It is found that when different values are passed from the parent component to this common child component, the values are the same. God, come and ask for help

.
Jul.22,2021

feels like there's something wrong with your posture when you register or use a subcomponent. There is no case code, no further thinking.


update the problem description and test it in depth again. It is found that when different values are passed from the parent component to this common child component, the values are the same. God, come and ask for help

there is no specific code that is difficult to explain, you can simplify it a little bit. As you can see from your sentence, it may be that there is a problem with the setting when passing the value of prop , or it may be that you have said that the sub-component is public, so there may be reuse problems caused by the life cycle of the sub-component . It is recommended that you query it again or add the code

.

you can consider the life cycle of parent and child components
https://blog.csdn.net/blueblu.
https://blog.csdn.net/michael.
https://www.jianshu.com/p/dae.


recently so busy that I forgot this question. Finally found the reason, indeed in the question when there is no specific code can not give an accurate train of thought; The reason for this problem is that layUI is introduced into this page. When rendering form elements, layUI listens on all initialized form elements and hides them and renders them again. In the sub-component I wrote, once this sub-component is created, the form elements in the newly created sub-component will overwrite the originally created one, causing all component states to be overwritten by the last created component.
solution: when listening to layUI form elements, do not listen to form elements uniformly, but separately to prevent this from happening.
Thank you for your advice.
ps: if you use Mvc frameworks such as vue, use layUI with caution

Menu