一、创建项目
1.切换到我们需要创建项目的目录,在这个目录下打开cmd
2.vue create 项目名
3.选择需要特性
(1)选择预置的内容,手动配置
Please pick a preset:Manually select features
(2)选择你项目所需要的特性
Check the features needed for you project:
①Choose Vue version
②Babel
③Router
④Vuex
⑤CSS Pre-processors
⑥Linter/Formatter
(3)选择vue版本
Choose a version of Vue.js that you want to start the project with(User arrow keys)
2.x
(4)选择路由模式 (输入y和n都可以,y代表history模式没有#号, n代表hash模式有#号)
Use history mode for router? (Requries proper server setup for index fallback in production)(Y/n)
y
(5)选择css预处理器,根据需求自行选择
Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported by default):
Less
(6)格式化和代码检测的配置,默认的就行
Pick a linter / formatter config:(Use arrow keys)
ESLint with error prevention only
(7)代码格式检测时机,默认就行
Pick additional lint features :(Press <space> to select, <a> to toggle all, <i> to invert selection )
Lint on save
(8)你希望配置放在哪
Where do you prefer placing config for Babel ,ESLint ,etc.?
In package.json
(9)是否保存特性,根据你的需求来
Save this as a preset for future projects?(y/N)
n/y
4.根据提示运行程序,按照以上运行为npm run serve
5.根据弹出的网址复制网页打开即可!
二、项目创建后各文件(夹)的作用
1.niode_moudles
所有的项目依赖都会下载到这个地方
2.public
存放公共资源和项目的主入口文件index.html
3.src
项目核心文件夹:包括项目源码各种静态资源等等。是我们开发的重点工作目录
4.assets
项目资源,img图片、视频、音频等
5.components
小组件,一般做子组件,对应views中页面级别的大组件
6.router
路由相关配置
7.store
Vuex相关配置
8.views
页面级别大组件
9.App.vue
App.vue是根组件,所有内容都在它里面
10.main.js
入口函数
11..gitignore
git配置上传时忽略文件
12.babel.config.js
babel的配置文件,babel主要作用是将ES6+的语法转化为ES5
13.package(-lock).json
带有-lock是本地的意思,项目配置,用于管理项目的依赖项,脚本,版本等。
14.package.json
项目配置,用于管理项目的依赖项,脚本,版本等。
15.README.md
项目介绍文件,对项目的主要信息进行描述