vue-learning:0 - 目录
Vue-learning
vue.js学习路径

Vue的API地图
视图层
点击可直接到达详情页面
指令
样式
特殊特性
过渡动画
模板形式
逻辑层
通用配置选项option
生命周期钩子函数
beforeCreatecreatedbeforeMountmountedbeforeUpdateupdatedbeforeDestorydestoryactivated(keep-alive)deactivated(keep-alive)
组件 Component
-
组件的概念
-
组件的构建和注册
- 构建:
com = Vue.extend(option) - 注册:
Vue.component('my-com', com)/vm.components: {'my-com': com} - 语法糖:
Vue.component('my-com',option)vm.components('my-com': option) - 组件命名规范
- 构建:
-
组件三大API:
prop/event/slot
prop- 字符串数组形式:
props: ['prop1', 'prop2', ...] - 对象形式:
type / required / defalut / validator - prop的命名规范
- 动态prop(除字符串外,其它类型传入都需要使用动态prop,即v-bind绑定)
- 单向数据流
- 非prop特性:
inheritAttr: false; / $attrs
event
v-on / $on监听事件$once一次性事件$emit触发事件$off卸载事件监听$listenersv-on绑定监听器集合(除原生监听事件).native原生事件修饰符.sync双向绑定修饰符model属性
slot
- 普通插槽
<slot></slot> - 插槽提供默认值
<slot>default content</slot> - 具名插槽
<slot name="someName"></slot> <!-- 组件调用 --> <my-com> <template v-slot:somName></template> <my-com> - 作用域插槽
<slot :prop="value"></slot> <!--组件调用 --> <my-com> <template v-slot='childValue'>{{ cilidValue.value}}</template> </my-com> - 独占默认插槽的写法
<some-component v-slot="childValue"> {{ childValue.value }}</some-component> <some-component v-slot:default="childValue"> {{ childValue.value }}</some-component> - 解构插槽prop
<my-com v-slot="{value}">{{ value }}</my-com> <!-- 重命名 --> <my-com v-slot="{value: otherName}">{{ otherName }}</my-com> <!-- 重命名并提供默认值 --> <my-com v-slot="{value: {otherName: defaultValue}}">{{ otherName }}</my-com> - 动态插槽名
<my-com> <template v-slot:[dynamicSlotName]></template> </my-com> v-slot的简写#<my-com> <template #:somName></template> <my-com>- 模板编译作用域 和 插槽作用域
- 字符串数组形式:
-
组件实例的调用
ref$root$parent$children
-
组件间的通信
- 父子组件通信
prop / $emit - 三层嵌套组件
$attrs/$liteners - 后代组件通信
provide / inject - 组件实例引用
$root/$parent/$children/$refs - 事件总线
const Bus = new Vue() - 状态管理器
Vuex
- 父子组件通信
-
动态组件
is -
异步组件
工厂函数 -
函数式组件
functional -
内置组件
transiton/keep-alive -
其它
- 组件的递归调用
- 组件的循环引用
v-once创建静态组件
路由 Vue-router
- 前端路由历史
- 服务端渲染(SSR:server side render)
- 客户端路由(client side routing)
- 前端路由实现原理
- hash模式: location.hash 和 hashChange事件
- history模式: history 和 popstate事件
- vue-router
- const router = new VueRouter(option)中的选项对象option
- 路由器实例对象router
- 路由对象route
- router-link标签的特性
- router-view标签的特性
- 路由传参的5种方式
1.路由动态参数: '/user/:userId'和params
2.命名路由传参,使用name和paramsconst route = {path: '/user/:userId'} this.$router.push({path:`/user/${userId}`}) this.$route.params.userId
3.查询参数传参,使用path和queryconst route = {name:'home',...} this.$router.push({name:'Login',params:{id:'leelei'}}) this.$route.params.id
4.prop形式:布尔/对象/函数this.$router.push({path:'/login',query:{id:'leelei'}) this.$route.query.idconst route = [{prop:true, ...}] const route = [{prop: {someProp:'someValue'}] const routes =[{props: (route) => ({ query: route.query.q }),...}]- meta元信息定义数据
// 定义路由时,定义元信息 const routes = [ {meta: {someData:'someData'},... }, // 获取数据 this.$route.meta.someData - 从路由中获取组件实例
const matchedComponents: Array<Component> = this.$router.getMatchedComponents(location?)
状态管理 Vuex
- 状态管理的概念
- vuex基本使用
- Vuex对象
- option选项
- store实例对象的属性: state, getters
- store实例对象的方法
- commit / dispatch
- 注册和卸载plugin的方法
- 注册和卸载Module的方法
- vuex的辅助函数: mapState / mapGetters / mapMutaions / mapActions
- vuex的项目结构组织
单元测试 vue-test-utils
项目构建vue-cli
进阶内容
- 响应式原理
- 虚拟DOM
- 模板编译原理
Vue API和vm API
浙公网安备 33010602011771号