[英]Migrating to Nuxt 3 from Vue 2?
There is a medium-sized application written in Vue 2.7 (vuex, vue-router, etc.).有一个用 Vue 2.7 编写的中型应用程序(vuex、vue-router 等)。
Until a certain point, we had SSR "with our own hands."直到某个时候,我们“亲手”拥有了 SSR。 Works crookedly and slowly, but works.弯曲而缓慢地工作,但有效。
Recently, it has ceased to satisfy the needs of the project and we realized that we would be migrating to Nuxt.最近,它不再满足项目的需求,我们意识到我们将迁移到 Nuxt。
Relatively recently, Nuxt 3 was released.最近,Nuxt 3 发布了。 It is now in rc state.它现在位于 rc state 中。 We are betting on the further development of Nuxt.我们押注于 Nuxt 的进一步发展。 Therefore, we want to migrate to version 3. In addition, I think that in the near future we will consider switching to TypeScript, and in Nuxt 3 TS support is at a good level.因此,我们想迁移到版本 3。另外,我认为在不久的将来我们会考虑切换到 TypeScript,并且在 Nuxt 3 TS 支持处于良好水平。
But there is an ambiguity: Nuxt 3 works with Vue 3. Also, it is recommended to use pinia instead of Vuex.但是有一个歧义:Nuxt 3 与 Vue 3 一起使用。另外,建议使用 pinia 而不是 Vuex。
In this regard, questions:在这方面,问题:
I would first off migration from Vue2 to Nuxt2, for the simplest + fastest approach without too many breaking parts.我会首先从 Vue2 迁移到 Nuxt2,这是最简单 + 最快的方法,没有太多的破坏部分。 That way, you can at least benefit of some SSR capabilities until your whole migration is done.这样,在整个迁移完成之前,您至少可以受益于一些 SSR 功能。
Then, as Estus Flask said , the main issue would be the packages themselves (like Vuetify, which are still not fully Vue3 compatible in a stable state).然后,正如Estus Flask 所说,主要问题将是包本身(如 Vuetify,在稳定状态下仍不完全兼容 Vue3)。
Also, you can totally migrate to Nuxt3 while keeping most of your components with the Options API (no need to refacto towards Composition API).此外,您可以完全迁移到 Nuxt3,同时使用选项 API 保留大部分组件(无需重构为 Composition API)。
Nuxt3 is runnable in production but you may still need to troubleshoot it depending on what you are planning to use. Nuxt3 可在生产中运行,但您可能仍需要根据您计划使用的内容对其进行故障排除。 Also, keep in mind that not all the modules are migrated yet , here is the latest roadmap .另外,请记住,并非所有模块都已迁移,这是最新的路线图。
So to answer your questions:所以回答你的问题:
useAsyncData
composables etc... So the same work will be needed there too, hence why I recommend a transition to Nuxt2 first. Nuxt3 使用的是 Vue3,因此您需要更多地了解 API 组合如何工作,以获得使用useAsyncData
组合等的好处......所以那里也需要同样的工作,因此我建议先过渡到 Nuxt2 . Of course, it all depends of your team and if your members are already at ease with Composition API当然,这完全取决于您的团队以及您的成员是否已经对组合 API 感到放心Overall, if you need a production-grade solution for your SSR needs, it will be quite useful to use Nuxt for sure but it will also require a bit of a learning curve.总的来说,如果你需要一个生产级的解决方案来满足你的 SSR 需求,那么使用 Nuxt 肯定会非常有用,但它也需要一些学习曲线。
You will also get quite some DX out of it, so that's a nice bonus!您还将从中获得相当多的 DX,所以这是一个不错的奖励!
Also, there is no real competition to Nuxt in Vue's ecosystem so at least, you don't need to fully compare meta-frameworks.此外,在 Vue 的生态系统中,Nuxt 没有真正的竞争对手,所以至少,你不需要完全比较元框架。 AstroJS could be another approach but it goes out from the Vue ecosystem quite a lot overall (you won't benefit of Nuxt's modules/nice features for example) and solves some specific needs. AstroJS可能是另一种方法,但它总体上脱离了 Vue 生态系统(例如,您不会受益于 Nuxt 的模块/不错的功能)并解决了一些特定需求。
PS: Nuxt's team is working on the same approach regarding server-only components + heavy improvements regarding the hydration. PS:Nuxt 的团队正在研究关于仅服务器组件的相同方法 + 关于水合作用的重大改进。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.