第一步:安装脚手架
1. 全局安装脚手架
npm install -g @vue/cli
2. vue -V:查看版本号。
第二步:在终端输入命令创建项目
1. 输入 vue create objectName 项目的名字需要小写。
2.
default (babel, eslint) 默认安装
> Manually select features 手动选择安装*****
3.
? 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
选中与取消请按空格键,选中后按回车进入下一步;
备注:通常选择这三个,一个路由,一个Vuex,一个css样式(sass或less两者都支持选择器嵌套,定义变量不一样)
( ) Router
( ) Vuex
( ) CSS Pre-processors
4.
是否使用router当中的history模式。hash。 yes (这里选择路由模式,有history和hash两种)
? Use history mode for router? (Requires proper server setup for index fallback in production) (Y/n)
5. 是否将你的配置信息包存到package.json中
> In dedicated config files // 单独存放配置信息
In package.json// 存放 到package.json
6. Save this as a preset for future projects? (y/N) 是否将你创建脚手架的信息进行保存。yes
第三步:运行项目
输入命令:
cd project-name //进入项目文件夹
cnpm run serve //运行刚创建好的项目