何时使用 @types

huangapple go评论102阅读模式
英文:

When to have @types

问题

当我阅读一些教程,就像这个这里一样,
我注意到作者介绍了@type

由于我对Vue还很陌生,我不知道@type是什么!而且我在我的.vue项目中找不到它。

请告诉我在什么情况下我需要使用@type以及它应该包含什么内容。

英文:

As I am reading some tutorials just like this one here
I noticed the author has introduced @type

as I am new into vue, I do not know what @type is! and iI do not have it in my .vue project.

would you please tell me in what scenario or case I would need to have @type and what it should container

答案1

得分: 1

@/types 指的是一个名为 types 的文件夹,@ 表示该文件夹不是 npm 包(更多信息请参见以下 链接)。
通常,您会创建此文件夹来存储与您的应用程序相关的接口/类型(更多信息请参见以下 链接)。
在教程中,您可以看到它导入了一个名为 Product 的类型,该类型来自该文件夹。
我希望我能帮助您。
祝您未来好运!

历史上,Vue 在其框架中使用 JavaScript 作为编程语言。此外,Microsoft 开发了 TypeScript,正如其名称所示,它是一种类似于 JavaScript 但带有类型的语言。您可以在我的第二个回复中的链接中阅读有关此主题的文档。
正如您帖子中的教程中所提到的,Typescript 现在在 Vue 的版本 3 中受支持。在您的帖子教程中,作者选择使用 Typescript,因此可以使用 Typescript 提供的类型/接口,我在我的回答中已经解释过了。
希望这对您更加清晰。
我只能建议您阅读 Typescript 文档,并在将来的 Vue 应用程序开发中使用这种语言。
此外,Vue 文档中提供了许多使用 Typescript 的示例。

英文:

@/types refers to a folder called types the @ means the folder is non-npm packages (see more at the following link for more information)
Usually you create this folder in order to store your interface/types related to your application. (see more at the following link for more information)
In the tutorial you can see that is importing a type called Product from this folder.
I hope I was able to help you.
good luck for the future !

Edit :
Historically, Vue used javascript as the programming language in its framework. In addition to this, Microsoft has developed Typescript which, as its name suggests, is a language similar to Javascript but with types. You can read the documentation on this subject in the link in my second reply.
As mentioned in the tutorial in your post, Typescript is now supported in version 3 of Vue. In the tutorial of your post, the author makes the choice to use Typescript and thus Types/Interface that Typescript propose as I was able to explain it in my answer.
I hope this is clearer for you.
I can only advise you to read the Typescript documentation and to use this language in the development of your future Vue applications.
In addition, the vue documentation is very well provided with examples using Typescript.

huangapple
  • 本文由 发表于 2023年6月9日 13:32:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/76437458.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定