gpt4 book ai didi

vue.js - 我是否必须在 Vue 3 中使用 Composition API,或者我仍然可以以 "Vue 2"的方式做事?

转载 作者:行者123 更新时间:2023-12-04 07:19:12 24 4
gpt4 key购买 nike

是否可以安装 Vue 3,但仍然以“Vue 2”的方式做事?换句话说,我看到 Vue 3 有新的 Composition API,但是在 Vue 3 中这是可选的还是必需的做事方式?
出于某种原因,我认为 Vue 3 仍然允许您以 Vue-2 的方式做事,而是使用 Options API。不是这样吗?谢谢。

最佳答案

Vue 3 不需要使用 Composition API。正如两位 Vue 核心团队成员所解释的,Options API 仍然可用并且不会被删除:
Thorsten LünborgVue 3: Data down, Events up (19-MAY-2020) :

IMPORTANT: The composition API is additive, it’s a new feature, but it doesn’t and will not replace the good ole “Options API” you know and love from Vue 1 and 2. Just consider this new API as another tool in your toolbox that may come in handy in certain situations that feel a little clumsy to solve with the Options API.


Ben HongEnjoy the Vue #48: "New in Vue 3: The Composition API" (19-JAN-2021) :

[00:01:03] T: Yeah. Well, the first thing I remember hearing was that it was replacing the options API.

[00:01:08] BH: Big disclaimer. That isn’t happening. Big disclaimer.

...

[00:09:10] BH: [...] this is not something you need to go and rewrite your app in. [...] the composition API is not like, drop the options do composition. It's an additive thing that when you have a problem that it can solve, it's really great for that.


early RFC for the Composition API只考虑过弃用 Options API:

A previous draft of this RFC indicated that there is the possibility of deprecating a number of 2.x options in a future major release, which has been redacted based on user feedback.

关于vue.js - 我是否必须在 Vue 3 中使用 Composition API,或者我仍然可以以 "Vue 2"的方式做事?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68611657/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com