简体   繁体   中英

Component Data Flow [VueJS]

I'm newbie in Vuejs. I have a question about structure data flow

If we have a component which's used in many other components( 3-4 components).

For example it's <CreateCard/> component, so should we put API in own <CreateCard/> component and pass props from parent for API or we should put API in parent of <CreateCard/> component.

Which is optimize solution? If you guys have any article or tutorials about struturing data flow, construct complex components well, please give me a recommendation

Thank you guys so much for helping me.

well, for me in such a case I will follow "when in doubt, split it out". splitting the files and dividing the responsibility is always better, I prefer to put all the API calls and vuex tools in a separated directory, and using slots in the reusable components. here are 2 articles I found for most common tips regarding VueJs best practices https://www.telerik.com/blogs/10-good-practices-building-maintaining-large-vuejs-projects

https://itnext.io/how-to-structure-my-vue.js-project-e4468db005ac

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM