一、安装node.js(开发需要的环境)
1、下载地址为:https://nodejs.org/en/
检查是否安装成功:如果输出版本号,说明我们安装node环境成功
//node版本号
node -v
//npm版本号
npm -v
2、为了提高效率,安装淘宝镜像
以后还是用npm命令,速度可能会快些
npm install -g cnpm –registry=https://registry.npm.taobao.org
检查淘宝镜像是否安装成功:
cnpm -v
(如果没报错可忽略这步) 如果输入cnpm -v 报<在此系统上禁止运行脚本>需要以管理员身份运行power shell,并输入
//以管理员身份运行power shell,并输入以下命令,并且选择A
set-ExecutionPolicy RemoteSigned
二、创建vue项目脚手架(新建项目时需要)
1、全局安装vue-cli
新版本全局安装vue-cli,相比较老版本主要是目录结构简洁些
cnpm install -global @vue/cli
检查是否安装成功:
vue -V
2、创建项目
按照步骤一步一步来就可以了
vue create vue-demo-name//vue-demo-name是项目的名称
Vue CLI v4.5.15
? Please pick a preset:
Default ([Vue 2] babel, eslint)
Default (Vue 3) ([Vue 3] babel, eslint)
> Manually select features//手动选择
Vue CLI v4.5.15
? Please pick a preset: Manually select features
? Check the features needed for your project:
( ) Choose Vue version
(*) Babel
( ) TypeScript
( ) Progressive Web App (PWA) Support
>(*) Router
( ) Vuex
( ) CSS Pre-processors
( ) Linter / Formatter
( ) Unit Testing
( ) E2E Testing
//是否使用history 模式
Vue CLI v4.5.15
? Please pick a preset: Manually select features
? Check the features needed for your project: Babel, Router
? Use history mode for router? (Requires proper server setup for index fallback in production) (Y/n) 我选择的 n 回车下一步
//配置信息存储位置
Vue CLI v4.5.15
? Please pick a preset: Manually select features
? Check the features needed for your project: Babel, Router
? Use history mode for router? (Requires proper server setup for index fallback in production) No
? Where do you prefer placing config for Babel, ESLint, etc.?
In dedicated config files
> In package.json
//是否作为模板为以后创建项目使用
Vue CLI v4.5.15
? Please pick a preset: Manually select features
? Check the features needed for your project: Babel, Router
? Use history mode for router? (Requires proper server setup for index fallback in production) No
? Where do you prefer placing config for Babel, ESLint, etc.? In package.json
? Save this as a preset for future projects? (y/N) //我选择N
以上就完成了创建vue项目,稍等下项目就自动创建好了,就可以用开发工具直接打开这个项目进行开发了
三、安装插件
3.1 安装element ui
npm i element-ui -S
卸载element ui
npm uninstall element-ui -D
3.2 安装 axios
npm install axios
3.2 安装 vuex
npm install vuex --save