VUE基础知识与搭建

安装node.js、vue3.0脚手架

1、安装node.js
https://nodejs.org/en/download/
查看版本号 node –v、npm –v 出现版本号即安装成功。(如未出现,请重启电脑后再试)node8.9或以上版本
2、管理nodejs版本(非必装)
执行命令安装:npm install -g n
n latest    (升级 node.js 到最新版)
n stable(升级 node.js 到最新稳定版)
n 后面也可以跟随版本号,例如:$ n v0.10.26 或者 $ n 0.10.26
3、全局安装 vue-cli3.0 脚手架
卸载:如果已经全局安装了旧版本的vue-cli(1.x或2.x),需要先卸载:npm uninstall vue-cli -g
安装:npm install -g @vue/cli
查看版本号:vue -V,出现版本号即安装成功。
3.0对2.0 版本的桥接:npm install –g @vue/cli-init
4、安装淘宝镜像 cnpm  (非必装,网络慢的情况可安装)
npm install -g cnpm –registry=https://registry.npm.taobao.org

建立项目仓库( Gitee 或 Github 或 Coding 或 Gitlab )

GIT基础命令(粘贴shift + insert)
拷备项目:git clone <仓库地址>
创建分支:git branch <name>
创建并进入分支:git checkout –b <nam>
查看状态:git status
添加所有文件:git add .
提交:git commit –m ‘这里是当前提交的描述’
拉取:git pull
推送:git push
查看分支:git branch –list
查看分支(包含远程分支):git branch -a

创建项目

vue create vue-admin

1
选择 Merge
2
选择 Manually select features
3
选择 Babel, Router, Vuex, Css Pre-processors, Linter / Formatter
4
选择 n
路由模式有两种:hash、historyhash – 即地址栏URL中的# 符号;如:http://www.abc.com/#/hellohistory – 利用了 HTML5 History Interface 中新增的 pushState() 和
replaceState() 方法。(这个方法就是面试中常问到的,怎么去除URL中的“#”号,此方法需要后端 Apache 或 Nginx 进行简单的路由配置,否则会报404。)注:这两个配置就是解决URL有没有 “#” 号的问题,如果不在意 “#”
号这个东西,就用hash。在意就用 history
5
选择 Sass/SCSS (with node-sass)
6
选择 ESLint + Prettier
7
选择 Lint on save
8
选择 In deficated config files
9
选择 N

依赖 element-ui

1、官网: https://element.eleme.cn/#/zh-CN
2、安装依赖

3、全局引入

5、vue.config.js https://cli.vuejs.org/zh/config/ 手册
6、配置全局样式

7、路由重定向redirect: “login”
8、安装API:

9、安装axios:

10、安装sha1加密:

 

SVG文件解释依赖

icons/index.js

icons/SvgIcon.vue

vue.config.js

Icon下载地址: https://www.iconfont.cn/collections/index?spm=a313x.7781069.1998910419.4&type=1

 

Cookie依赖安装

打包工具

分析文件大小插件

 

路由懒加载插件:

gzip压缩插件:

去除console减少文件大小插件

// webpack的配置在这个属性里修改configureWebpack

 

Vue2.0与Vue3.0生命周期

beforeCreate -> 请使用 setup()

created -> 请使用 setup()

beforeMount -> onBeforeMount

mounted -> onMounted

beforeUpdate -> onBeforeUpdate

updated -> onUpdated

beforeDestroy -> onBeforeUnmount

destroyed -> onUnmounted

errorCaptured -> onErrorCaptured