使用 vue-cli 工具和 airyland/vux2 模板快速初始化项目
在需要创建的目录下面打开cmd
1、# 全局安装 vue-cli
npm install vue-cli -g // 如果还没安装
2、# 创建一个基于 webpack 模板的新项目
vue init airyland/vux2
2
2.1、参数设置说明:
Generate project in current directory:是否在当前目录下生成项目
Project name 项目名称
Project description 项目描述
Author :作者
下面的都是选择部分
Vue build : 选 Runtime + Compiler: recommended for most users 运行加编译(推荐大部分人使用);
Use ESLint to lint your code? (Y/n) 是否使用ESLint管理代码,ESLint是个代码风格管理工具,是用来统一代码风格的,并不会影响整体的运行,这也是为了多人协作,新手就不用了,一般项目中都会使用。官网:http://eslint.org/
Pick an ESLint preset (Use arrow keys) :选择编写vue项目时的代码风格,根据个人爱好选择:
Standard (https://github.com/feross/standard)
AirBNB (https://github.com/airbnb/javascript)
none 自己定义风格
Setup unit tests with Karma + Mocha? (Y/n) 是否安装单元测试
Setup e2e tests with Nightwatch(Y/n)? 是否安装e2e测试
3、安装对应依赖
npm install --registry=https://registry.npm.taobao.org
(直接使用 cnpm 可能会导致依赖不正确。强烈建议给 npm 设置 taobao 的 registry。 )
image.png
4、npm run dev
image.png
npm run build 打包后在本地浏览,发现报错引入不到文件,需要修改config文件夹下index.js中assetsPublicPath选项'/'改为'./';
npm run 的命令大全可以在package.json中查看
服务器端口号在:config/index.js修改
运行成功
image.png