what will happen for vuejs projects based on class components in vuejs v3.0?

后端 未结 1 2054
庸人自扰
庸人自扰 2020-12-20 14:45

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 :

相关标签:
1条回答
  • 2020-12-20 15:08

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

    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.

    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

    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

    0 讨论(0)
提交回复
热议问题