vuejs v3.0 中基于 class 组件的 vuejs 项目会发生什么?
what will happen for vuejs projects based on class components in vuejs v3.0?
我想将我的 vuejs 项目升级到基于 class 组件的打字稿,但我在 vue 问题的 https://github.com/vuejs/rfcs/pull/17#issuecomment-494242121 中读到:
Update: the Class API proposal is being dropped.
那么现有的 class 基于组件的项目会怎样?
更重要的是,基于这篇文章:
https://alligator.io/vuejs/using-typescript-with-vue/ 这表示
Since we are not using the class-style syntax, you use the as keyword
to declare data as a data type.
这种在vue3.0中使用typescript的方式安全吗?
目前还没有基于class的官方API。 RFC 是关于添加一个,但由于那里讨论的原因而被删除。
现有项目正在使用 vue-class-component library which builds on top of official object-based component API (officially called Options API). This should continue to work in 3.0 (because Options API stays the same) but suffer from the same drawbacks mentioned in the RFC. Here 是维护者声明支持 Vue 3 的评论。
第二篇链接文章使用的是没有 vue-class-component
的 TypeScript - 没有 classes,只是常规的基于对象的组件 API + TypeScript 类型注释。所以是的,这将适用于 3.0
但是,如果您现在开始在 Vue 中使用 TypeScript,我强烈建议您看一下将在 3.0 中添加的 new composition API。它是官方 API(不是图书馆),与任何现有解决方案相比有很多好处。
由于 composition-api,您甚至可以在 Vue 2 中使用 Composition API - 这是一个插件,但计划使其正式化,更好地集成到 Vue 核心中并由 Vue 核心团队维护.
我基于组合 API 创建了一个 vue 3 class 组件。 Npm Package。如果发现任何错误或遗忘组合 API 问题中的功能,请使用它。
我想将我的 vuejs 项目升级到基于 class 组件的打字稿,但我在 vue 问题的 https://github.com/vuejs/rfcs/pull/17#issuecomment-494242121 中读到:
Update: the Class API proposal is being dropped.
那么现有的 class 基于组件的项目会怎样? 更重要的是,基于这篇文章: https://alligator.io/vuejs/using-typescript-with-vue/ 这表示
Since we are not using the class-style syntax, you use the as keyword to declare data as a data type.
这种在vue3.0中使用typescript的方式安全吗?
目前还没有基于class的官方API。 RFC 是关于添加一个,但由于那里讨论的原因而被删除。
现有项目正在使用 vue-class-component library which builds on top of official object-based component API (officially called Options API). This should continue to work in 3.0 (because Options API stays the same) but suffer from the same drawbacks mentioned in the RFC. Here 是维护者声明支持 Vue 3 的评论。
第二篇链接文章使用的是没有 vue-class-component
的 TypeScript - 没有 classes,只是常规的基于对象的组件 API + TypeScript 类型注释。所以是的,这将适用于 3.0
但是,如果您现在开始在 Vue 中使用 TypeScript,我强烈建议您看一下将在 3.0 中添加的 new composition API。它是官方 API(不是图书馆),与任何现有解决方案相比有很多好处。
由于 composition-api,您甚至可以在 Vue 2 中使用 Composition API - 这是一个插件,但计划使其正式化,更好地集成到 Vue 核心中并由 Vue 核心团队维护.
我基于组合 API 创建了一个 vue 3 class 组件。 Npm Package。如果发现任何错误或遗忘组合 API 问题中的功能,请使用它。