![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
vuex3源码解读
望月寄明
学习是件快乐的事情
展开
-
vuex,vue-router源码系列注释说明
最近有点忙,不能及时更新对应的注释文章。关于更新内容不适合博客阅读的说明:1、更新内容只是为了自己回顾,以及帮助在看源码的同学可以对比,而不是教人从0到1的学会源码如何实现。所以没注意内容排版。2、vuex3,vuex-persistence 的源码注释的是 github 仓库地址, 能点 star 的说声谢谢。3、vue-router 会在 4-23 号之前更新完,但因为开发任务比较重,只能不定时更新了。4、紧接着是 axios, vue 的源码,然后是 vuex4, vuerouter4,vu原创 2022-03-24 10:02:15 · 462 阅读 · 1 评论 -
vuex3.0源码注释系列 vuex-persistedstate源码注释
import { Store, MutationPayload } from "vuex";import merge from "deepmerge";import * as shvl from "shvl";interface Storage { getItem: (key: string) => any; setItem: (key: string, value: any) => void; removeItem: (key: string) => void;}原创 2022-03-19 10:59:26 · 693 阅读 · 0 评论 -
vuex3源码注释系列 /src/helper.js mapState,mapMutation,mapGetter,mapAction 源码解析
import { isObject } from "./util";/** * vuex 中使用的四个辅助函数的来源文件 /src/helpers.js。 * mapState, * mapMutations, * mapGetters, * mapActions, * createNamespacedHelpers *//* mapState 经过 调用normalizeNamespace() 之后,返回的结果,这个结果就是个函数。 我们调用的 mapState 是如下函数:原创 2022-03-17 11:22:22 · 918 阅读 · 0 评论 -
vuex3源码注释系列 /src/store.js
import applyMixin from "./mixin";import devtoolPlugin from "./plugins/devtool";import ModuleCollection from "./module/module-collection";import { forEachValue, isObject, isPromise, assert, partial } from "./util";let Vue; // bind on install/*** * V原创 2022-03-16 20:17:56 · 864 阅读 · 0 评论 -
vuex3源码注释系列 /src/plugins/logger.js
// Credits: borrowed code from fcomb/redux-loggerimport { deepCopy } from "../util";/** * 关于 createLogger 的使用: ===> 以插件的方式进行使用。用于打印 vuex 使用过程中的消息日志。 * import { createLogger } from 'vuex'; const store = new Vuex.store({ state: {},原创 2022-03-16 11:24:39 · 327 阅读 · 0 评论 -
vuex3源码注释系列 /src/module/module-collection.js
import Module from "./module";import { assert, forEachValue } from "../util";/** * rawRootModule 参数就是 Vuex.Store(options) 中的 options 值。 * * ModuleCollection 实例。在 store 对象上是 store._modules 属性。 * { * root: 指向 rawModule 第一层的数据转换成的 Module 实例原创 2022-03-16 10:33:49 · 199 阅读 · 0 评论 -
vue源码注释系列 /src/module/module.js
import { forEachValue } from "../util";// Base data struct for store's module, package with some attribute and methodexport default class Module { /** * rawModule 就是 { * actions: {}, * state: {}, * mutations: {}, * getters: {}, *原创 2022-03-15 20:24:37 · 877 阅读 · 0 评论 -
vuex3源码注释 /res/plugins/devtool.js
···//设置环境const target =typeof window !== “undefined”? window: typeof global !== “undefined”? global: {};//用于判断是否使用了开发者工具 devtoolconst devtoolHook = target.VUE_DEVTOOLS_GLOBAL_HOOK;export default function devtoolPlugin(store) {//如果没有安装,直接退出。if (原创 2022-03-15 20:21:47 · 202 阅读 · 0 评论 -
vuex3源码注释系列 /res/utils.js
/* 查找list中是否有符合条件的元素。*/export function find(list, f) { return list.filter(f)[0];}/** * 深度拷贝 * 这个深度拷贝不能实现对 RegExp,Date 对象的拷贝。 */export function deepCopy(obj, cache = []) { //如果 obj 是 null, 或者不是对象,则直接返回。 可以理解为 null 和 基本信息就直接返回。 if (obj === .原创 2022-03-15 19:35:56 · 276 阅读 · 0 评论 -
vuex3.0源码注释系列 /src/mixin.js
通过 vue.use(Vuex) 开始执行 Vuex.install(_vue) 方法Vuex.install 不是来自于 Store 类对象,而是一个在 Store.js 文件中单独写的一个函数。# /src/store.js 文件import applyMixin from './mixin'/** Vuex.Store 本章没有涉及到 Vue.Store 内容,所以隐藏不展示。*/export class Store { xxxxxxx}/*** * Vuex.instal原创 2022-03-11 10:23:42 · 730 阅读 · 0 评论 -
vuex3.0源码注释系列 vuex入口文件/src/index.js
import { Store, install } from './store'import { mapState, mapMutations, mapGetters, mapActions, createNamespacedHelpers } from './helpers'import createLogger from './plugins/logger'/*** * 这个就是 Vuex 类的文件。 * 第一步是 vue.use(Vuex), 所以先走 Vuex 的 install(原创 2022-03-11 10:12:04 · 426 阅读 · 0 评论