美文网首页
Vue3.x脚手架搭建

Vue3.x脚手架搭建

作者: 翌凌枫 | 来源:发表于2019-05-27 17:03 被阅读0次

一、Vue项目搭建前准备

Vue CLI 是一个基于 Vue.js 进行快速开发的完整系统:
安装版本:@vue/cli 3.x 版本
前期准备:需提前安装好node和npm,用npm -v 和 node -v 测试版本号

  1. 查看当前vue/cli的版本号 —— vue --version
  2. 获取帮助,查看vue/cli的命令合集 —— vue -h
  3. 新建项目 —— vue create xxx
  4. 运行项目 —— npm run serve (本地时用)
  5. 打包部署 —— npm run build (上线时用)

二、vue/cli脚手架安装流程

  1. 在终端中:输入(npm install -g @vue/cli)安装手脚架工具。全局安装,输入(vue --version)查看当前安装的版本号。

  2. 创建新的项目
    输入"vue create vueapp" 创建项目,并选择预设,使用default(系统默认预设)还是 manually select features(手动选择预设)。

vue create  vueapp (新建项目名)

Vue CLI v3.8.2
? Please pick a preset:
  default (babel, eslint)
> Manually select features
  1. 手动选择时,通过键盘上(PgUp)下(PgDn)箭头选择,空格键选中,回车确认提交。
Vue CLI v3.8.2
? Please pick a preset: Manually select features
? Check the features needed for your project:
 (*) Babel
 ( ) TypeScript
 ( ) Progressive Web App (PWA) Support
 ( ) Router
 ( ) Vuex
>(*) CSS Pre-processors
 (*) Linter / Formatter
 ( ) Unit Testing
 ( ) E2E Testing
一般选择:Babel  Router   Vuex   Css Pre
  1. 选择css样式预处理程序,使用Sass/Scss
> Sass/SCSS (with dart-sass)
  Sass/SCSS (with node-sass)
  Less
  Stylus
  1. 选择ESLint规则,使用Standard config(标准配置)。
  ESLint with error prevention only
  ESLint + Airbnb config
> ESLint + Standard config
  ESLint + Prettier
  1. 选择是在保存时Lint还是提交时Lint。
>(*) Lint on save
 ( ) Lint and fix on commit
  1. 配置文件存放在哪里?
> In dedicated config files
  In package.json

8.是否保存这次配置的预设。 N(选择不保存)
···
? Save this as a preset for future projects? (y/N)N
···
9 .安装成功,cd xxx(进入你创建的项目目录下),输入npm run serve启动项目(vue/cli2.x使用的是npm run dev)。

npm run serve   本地编程模式下
npm run bulid   上线生产模式下
  1. 访问地址可以通过本地Local访问或者通过本机ip地址访问,npm run build指的是版本打包部署指令。
App running at:
  - Local:   http://localhost:8080/
  - Network: http://192.168.1.1:8080/

  Note that the development build is not optimized.
  To create a production build, run npm run build.

相关文章

网友评论

      本文标题:Vue3.x脚手架搭建

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