在Laravel中一起使用React.js和Vue.js [英] Using React.js and Vue.js Together in Laravel

查看:177
本文介绍了在Laravel中一起使用React.js和Vue.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的很想知道,是否可以在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?

推荐答案

是.绝对有可能.多种语言编程是当今的现实.您可以采取几种方法.最常见的方法是 微前端 .

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组件不是很友好.在许多高级测试中失败.

这篇关于在Laravel中一起使用React.js和Vue.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆