[英]Vue.js application architecture, focusing on reusability and scalability
I'm working on an Application which is already build for one country. 我正在开发已经为一个国家/地区构建的应用程序。 Now it is required to scale it to multiple countries (20+) with minor changes in each component.
现在需要将其扩展到多个国家(超过20个),每个组成部分都需要进行微小的更改。 How to implement for making code reusable and scalable, ways I thought:
我如何实现使代码可重用和可伸缩的实现:
App structure/Code: There is a form whose fields and validations will change based on country. 应用程序结构/代码:存在一种表格,其字段和验证将根据国家/地区而变化。 Plus few banners whose banner layout is based on country.
加上少量横幅,其横幅布局基于国家/地区。
Would like to know how we can architect such Vue.js Application ? 想知道我们如何构建这样的Vue.js应用程序?
很难看到所有代码,但是如果您已经在使用i18n更改语言字符串并且所做的更改确实很小,我认为v-if是您的最佳选择。
Instead of having v-ifs, I'd delegate this logic to a custom component: 我没有使用v-if,而是将此逻辑委托给自定义组件:
Instead of: 代替:
<h2>Country Specific</h2>
<v-if="country=='A'>
<v-if="country=='B'>
<v-if="country=='C'>
etc...
Do this: 做这个:
<h2>Country Specific</h2>
<custom-module country="currentCountry"/>
and group all these "per country" modules under a specific folder separate from your "global/shared" system. 并将所有这些“按国家/地区”模块分组到与“全球/共享”系统分开的特定文件夹下。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.