简体   繁体   English

如何在一个项目中实现多个前端javascript框架?

[英]How would one implement multiple front end javascript frameworks in one project?

How would you divide their implementation for a website for example? 例如,您如何划分网站的实施? Do you divide it between different features, pages, etc. or can you implement it in the same division? 您是将其划分为不同的功能,页面等,还是可以在同一划分中实现?

I would suggest writing modular javascript and using a bundler like Browserify or Webpack . 我建议编写模块化的javascript并使用诸如BrowserifyWebpack之类的捆绑 With both, you're able to tap into a world of NPM JavaScript packages. 通过这两者,您可以利用NPM JavaScript软件包的世界。 For custom project code, keep it modular module.exports = function() {...} . 对于自定义项目代码,请将其保留为模块化module.exports = function() {...} Organize code locally first by what is common/shared. 首先通过通用/共享在本地组织代码。 Then by screen and then after that by component if it makes sense. 然后按屏幕,然后再按组件(如果有)。

dir/ DIR /
..shared/ ..共享/
....header/ ....页眉/
....footer/ ....页脚/
..screen/ ..屏幕/
....home/ ....家/
......intro/ ......介绍/
....about/ ....关于/
......jobs/ ......工作/

With Webpack, you can then use the code-splitting features to split up bundles in ways that make the most sense for browser caching & lazy-loading. 借助Webpack,您可以使用代码拆分功能以最适合浏览器缓存和延迟加载的方式拆分包。 All that said, I don't think there's a magical answer, right every time, for all apps. 综上所述,我认为对于所有应用程序而言,每次出现的答案都不是一个神奇的答案。 It's probably best to start with a strategy and be flexible. 最好是从战略入手并保持灵活性。 Change it based on how the app evolves and the efficiency with how the team works with it. 根据应用程序的发展方式以及团队的效率来对其进行更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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