我是否必须在 Vue 3 中使用 Composition API,或者我仍然可以按照 "Vue 2" 的方式做事吗?
Do I have to use the Composition API in Vue 3, or can I still do things the "Vue 2" way?
是否可以安装 Vue 3,但仍然以“Vue 2”方式进行操作?换句话说,我看到 Vue 3 有新的 Composition API,但在 Vue 3 中这是可选的还是必需的做事方式?
出于某种原因,我认为 Vue 3 仍然允许您使用选项 API 以 Vue-2 的方式做事。不是这样吗?谢谢
Vue 3 不需要使用组合 API。选项 API 仍然可用,不会被删除,正如两位 Vue 核心团队成员所解释的:
Thorsten Lünborg in Vue 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 Hong in Enjoy 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 只考虑弃用选项 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 docs也证实了这一点:
Will Options API be deprecated?
No, we do not have any plan to do so. Options API is an integral part of Vue and the reason many developers love it. We also realize that many of the benefits of Composition API only manifest in larger-scale projects, and Options API remains a solid choice for many low-to-medium-complexity scenarios.
是否可以安装 Vue 3,但仍然以“Vue 2”方式进行操作?换句话说,我看到 Vue 3 有新的 Composition API,但在 Vue 3 中这是可选的还是必需的做事方式?
出于某种原因,我认为 Vue 3 仍然允许您使用选项 API 以 Vue-2 的方式做事。不是这样吗?谢谢
Vue 3 不需要使用组合 API。选项 API 仍然可用,不会被删除,正如两位 Vue 核心团队成员所解释的:
Thorsten Lünborg in Vue 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 Hong in Enjoy 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 只考虑弃用选项 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 docs也证实了这一点:
Will Options API be deprecated?
No, we do not have any plan to do so. Options API is an integral part of Vue and the reason many developers love it. We also realize that many of the benefits of Composition API only manifest in larger-scale projects, and Options API remains a solid choice for many low-to-medium-complexity scenarios.