How to improve the Componentialization of Vue

when writing a component, I don"t know whether my logical code should be placed in the component or in its parent component. The method is called through the parent component, and the data is obtained and passed into the child component. The child component is only responsible for rendering the data.

I don"t know which way is better. In other words, in which case which way is better. Is there a boss who can solve my doubts? Thank you ~

Mar.28,2021

if multiple child components use the same method, the method is placed in the parent component.
if a subcomponent only uses a method that only reflects itself, put that method into the subcomponent.
if multiple components (regardless of parents / children) need to use the same method, put the method in a global location for easy use, such as in root/util/commonFunction.js

Menu