本文介绍了基于vuejs v3.0中的类组件的vuejs项目会发生什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将我的vuejs项目升级为基于类组件的打字稿,但是我读了vue问题的 https://github.com/vuejs/rfcs/pull/17#issuecomment-494242121 :

i wanna upgrade my vuejs project to typescript based on class components, but i read in vue issue's https://github.com/vuejs/rfcs/pull/17#issuecomment-494242121 :

那么现有的基于类组件的项目会发生什么呢?更重要的是,根据本文: https://alligator.io/vuejs/using-typescript-with-vue/表示

so what will happen to existing class component-based projects?and more important, based on this article:https://alligator.io/vuejs/using-typescript-with-vue/ which says

在vue3.0中这种使用打字稿的方式安全吗?

is this way of using typescript safe in vue3.0?

推荐答案

当前没有官方的基于类的API. RFC即将添加一个,但由于此处讨论的原因而被删除.

Currently there is no official class-based API. RFC was about adding one but was dropped for the reason discussed there.

现有项目正在使用 vue-class-component 库,该库建立在官方的基于对象的组件API.这应该在3.0中继续起作用(因为基于对象的组件API保持不变),但存在相同的缺点中提到的/0000-class-api.md#motivation"rel =" nofollow noreferrer>. 此处是维护者的一则评论,宣布支持Vue. 3.

Existing projects are using vue-class-component library which builds on top of official object-based component API. This should continue to work in 3.0 (because object-based component API stays the same) but suffer from the same drawbacks mentioned in the RFC. Here is a comment from maintainer declaring support for Vue 3.

第二篇链接文章使用的是不带vue-class-component的TypeScript-没有类,只有常规的基于对象的组件API + TypeScript类型注释.是的,这将在3.0版本中起作用

Second linked article is using TypeScript without vue-class-component - no classes, just regular object-based component API + TypeScript type annotations. So yes, this will work in 3.0

但是,如果您现在开始在Vue中使用TypeScript,我强烈建议您看看将在3.0中添加的新组成API .它是一个官方API(不是库),与任何现有解决方案相比,都有很多好处. composition-api

However if you are starting with TypeScript in Vue now, I would strongly recommend to take a look at the new composition API which will be added in 3.0. It's an official API (not a library) and has many benefits compared to any existing solution. You can even use it now thanks to composition-api

这篇关于基于vuejs v3.0中的类组件的vuejs项目会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 16:02