[英]Using vue-cli-service with typescript
I have a Vue project that I created with the Vue CLI, and I now want to enable TypeScript on the project. 我有一个使用Vue CLI创建的Vue项目,现在我想在项目中启用TypeScript。 I took a look at this guide , but it recommends adding a Webpack config and replacing
vue-cli-service
in the package.json
scripts section with Webpack. 我看了一下这个指南 ,但它建议添加一个Webpack配置并用
package.json
替换package.json
scripts部分中的vue-cli-service
。
Is there any way I can continue to use vue-cli-service
to build my Vue app and enable TypeScript support for it? 有什么办法可以继续使用
vue-cli-service
来构建我的Vue应用程序并为它启用TypeScript支持吗?
In vue-cli 3.x 在vue-cli 3.x中
$ vue create <app_name>
This will bring up a prompt, select Manually select features
, enable TypeScript
using the space bar. 这将弹出提示,选择
Manually select features
,使用空格键启用TypeScript
。 It will automatically configure everything for you. 它会自动为您配置一切。
With an existing Vue CLI project, you can add TypeScript support by entering this command: 使用现有的Vue CLI项目,您可以通过输入以下命令添加TypeScript支持:
vue add typescript
Beware that this command will overwrite files, but you can use git diff
to view the differences. 请注意,此命令将覆盖文件,但您可以使用
git diff
查看差异。
我最终使用vue cli生成了一个新的vue项目,启用了typescript并复制了tsconfig并添加了package.json中缺少的包。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.