我真的很想知道,是否可以在 laravel 中并排使用 react.js 和 vue.js?
例如,将 ReactJs 用于管理仪表板,将 VueJs 用于客户端仪表板.我知道使用其中一种在技术上和逻辑上都更好.
你怎么认为?我们可以一起使用吗?
I really want to know, is it possible to using react.js and vue.js next to each other in a laravel?
For Example, use ReactJs for admin dashboard and use VueJs for client dashboard. I know it's technically and logically better to use one of them.
What do you think? Can we use them together?
是的.这绝对是可能的.多语言编程是当今的现实.您可以采取几种方法.最常见的方法是 micro-frontends.
Yes. It is definitely possible. Polyglot programming is today's reality. There are a couple of approaches you can take. A most common approach would be that of a micro-frontends.
如何实现微前端取决于您!但总的来说,您将在两条不同的路线上提供两种不同的 SPA.您将使用超链接/锚标记来链接这两个应用程序.但是,请注意,做一些成本很高的事情,对于非常大的应用程序和构建它们的团队来说确实意味着.
How you implement micro-frontend is up to you! But in general, you will have two different SPA served on two different routes. You will interlink these two applications using hyperlinks/anchor tags. However, note that, doing something that is a big cost and really meant for very large applications and teams building them.
有许多叶子组件,如按钮、链接、下拉列表等,您最终将为这两个框架开发和维护它们.将为每个框架重写状态管理、路由、服务.跨框架匹配一致的样式指南是非常痛苦的.
There are many leaf components like buttons, links, dropdown, etc. which you will end up developing and maintaining for both frameworks. State management, routing, services will be rewritten for each framework. It is incredibly painful to match consistent style guide across frameworks.
现在,如果您真的需要继续使用这种方法,您可以考虑为您的叶组件使用自定义元素.它们应该适用于许多 SPA 框架(请参阅注释).这将帮助您省去重新发明轮子的麻烦.
Nowadays, if you really need to go ahead with this approach, you can consider using custom-elements for your leaf components. They should work for many SPA frameworks (see the notes). This will help you save the trouble of reinventing the wheel.
注意:React 对 web 组件不是很友好.它在许多高级测试上都失败了.
Note: React is not very friendly with web-components. It fails on many advanced tests.
这篇关于在 Laravel 中同时使用 React.js 和 Vue.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!