ts定义数组类型_Vue3+TS,写一个逼格满满的项目

382b0efc536435c28f2adb30e2e41497.gif戳蓝字"Web前端严选"关注我们哦

Vue3和TS的概念学了那么多,有没有心动手痒想实践一下呢?

本次千字长文将手把手介绍如何使用Vue3+TS写一个基础项目,有了主要框架概念之后,后续对于应用的开发能更加地得心应手。

1.版本升级

大家之前在做Vue开发时想必都是2.x版本,在这个项目之前要先检查Vue处于哪个版本,本次示例需要4.5.3版本及以上:

vue --version
//@vue/cli 4.5.3

版本升级之后即可创建项目,使用的命令还同之前一样:

vue create project-name

下面展示的是创建示例项目过程中各个步骤的选择内容:

Vue CLI v4.5.8
? Please pick a preset: (Use arrow keys)
  Default ([Vue 2] babel, eslint)  //默认,vue2版本
  Default (Vue 3 Preview) ([Vue 3] babel, eslint) //默认,vue3版本
> Manually select features    //手动选择配置
? Check the features needed for your project: (Press  to select,  to toggle all,  to invert selection)
>(*) Choose Vue version  //选择vue版本
 (*) Babel
 (*) TypeScript
 ( ) Progressive Web App (PWA) Support
 (*) Router
 (*) Vuex
 (*) CSS Pre-processors
 ( ) Linter / Formatter
 ( ) Unit Testing
 ( ) E2E Testing    
? Choose a version of Vue.js that you want to start the project with (Use arrow keys)
  2.x
> 3.x (Preview)  
? Use class-style component syntax? (y/N)  N
//是否使用类样式组件
? Use Babel alongside TypeScript (required for modern mode, auto-detected polyfills, transpiling JSX)? (Y/n) N
//不需要babel去配合TS
? Use history mode for router? (Requires proper server setup for index fallback in production) (Y/n) Y 
//使用路由的历史模式
? Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported by default): (Use arrow keys)
> Sass/SCSS (with dart-sass)
  Sass/SCSS (with node-sass)
  Less
  Stylus 
//选择CSS预处理器
? Where do you prefer placing config for Babel, ESL
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值