美文网首页
Vue + Typescript项目搭建(1)

Vue + Typescript项目搭建(1)

作者: 钱英俊真英俊 | 来源:发表于2019-03-18 15:53 被阅读0次

1. 使用vue-cli3安装新模板

vue create projectName

2. Manually手动选择

3. 配置

Vue CLI v3.5.1
? Please pick a preset: Manually select features
? Check the features needed for your project: Babel, TS, Router, Vuex, CSS Pre-processors, L
inter
// 是否使用Class风格装饰器?
// 即原本是:home = new Vue()创建vue实例
// 使用装饰器后:class home extends Vue{}
? Use class-style component syntax? Yes

// 使用Babel与TypeScript一起用于自动检测的填充?
? Use Babel alongside TypeScript for auto-detected polyfills? (Y/n) 

// 路由使用历史模式? 这种模式充分利用 history.pushState API 来完成 URL 跳转而无须重新加载页面
? Use history mode for router? (Requires proper server setup for index fallback in productio
n) (Y/n) 

// Css预编译器
? 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 

// 检查格式
? Pick a linter / formatter config: (Use arrow keys)
❯ TSLint  // typescript格式验证工具
  ESLint with error prevention only  // 只进行报错提醒; 【选这个】
  ESLint + Airbnb config // 不严谨模式; 
  ESLint + Standard config // 正常模式;
  ESLint + Prettier // 严格模式;

// 检查时间
❯◉ Lint on save // 保存时检查
 ◯ Lint and fix on commit // commit 时检查

// 配置目录? Where do you prefer placing config for Babel, PostCSS, ESLint, etc.? 
❯ In dedicated config files  // 独立文件夹
  In package.json // json

// 为以后的项目保存配置
? Save this as a preset for future projects? (y/N) 

4. 安装运行

cd account
npm run serve
 App running at:
  - Local:   http://localhost:8083/ 
  - Network: http://192.168.1.108:8083/

然后就可以在本地打开了

相关文章

网友评论

      本文标题:Vue + Typescript项目搭建(1)

      本文链接:https://www.haomeiwen.com/subject/mlivmqtx.html