<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>NotionNext BLOG</title>
        <link>https://zxs-1024.cn/</link>
        <description>这是一个由NotionNext生成的站点</description>
        <lastBuildDate>Tue, 27 Feb 2024 08:55:52 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>zh-CN</language>
        <copyright>All rights reserved 2024, 张小手</copyright>
        <item>
            <title><![CDATA[vue mixins 让组件显得不再臃肿]]></title>
            <link>https://zxs-1024.cn/article/vue-mixins</link>
            <guid>https://zxs-1024.cn/article/vue-mixins</guid>
            <pubDate>Fri, 02 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[vue 提供了 mixins 这个 API，可以让我们将组件中的可复用功能抽取出来，放入 mixin 中，然后在组件中引入 mixin，可以让组件显得不再臃肿，提高了代码的可复用性。]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-94a1a53860394c439caff0682c4493b3"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-9d9f242387794c4697dd3783a5cdbbab" data-id="9d9f242387794c4697dd3783a5cdbbab"><span><div id="9d9f242387794c4697dd3783a5cdbbab" class="notion-header-anchor"></div><a class="notion-hash-link" href="#9d9f242387794c4697dd3783a5cdbbab" title="vue mixins 让组件显得不再臃肿"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">vue mixins 让组件显得不再臃肿</span></span></h2><div class="notion-text notion-block-07f3a909727f482085a6ebc08b2c5ef3">vue 提供了 mixins 这个 API，可以让我们将组件中的可复用功能抽取出来，放入 mixin 中，然后在组件中引入 mixin，可以让组件显得不再臃肿，提高了代码的可复用性。</div><div class="notion-text notion-block-a91e22904f6945219752dde9080ae25f">如何理解 mixins 呢 ？我们可以将 mixins 理解成一个数组，数组中有单或多个 mixin，mixin 的本质就是一个 JS 对象，它可以有 data、created、methods 等等 vue 实例中拥有的所有属性，甚至可以在 mixins 中再次嵌套 mixins，It’s amazing !</div><div class="notion-text notion-block-0b7c6af0af5a4d95a28869bc0c912d0a">举个简单的栗子:</div><div class="notion-text notion-block-a9138446b60d4b13a6a45598a968615d">mixins 与 Vue Instance 合并时，会将 created 等钩子函数合并成数组，mixins 的钩子优先调用，当 data、methods 对象键值冲突时，以组件优先。</div><div class="notion-text notion-block-04e9ad84de7045aba9e5f80902989fb3">PS: 如果对 mixins 的概念还不太清的小伙伴，可以去 <a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://cn.vuejs.org/v2/guide/mixins.html">vue 官方文档</a> 看一下 vue mixins 的基本概念和用法。</div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-44efbaddb866481a9dffc9840d7e6d7f" data-id="44efbaddb866481a9dffc9840d7e6d7f"><span><div id="44efbaddb866481a9dffc9840d7e6d7f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#44efbaddb866481a9dffc9840d7e6d7f" title="mixins 实现"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">mixins 实现</span></span></h3><div class="notion-text notion-block-39792e6304ee470097d48c91d1bd4e53">那 mixins 是如何实现的呢 ？当 vue 在实例化的时候，会调用 mergeOptions 函数进行 options 的合并，函数申明在 vue/src/core/util/options.js 文件。</div><div class="notion-text notion-block-8537a8e4de4742219f5a8937d7a849f2">为了保持代码简洁，已经将 mergeOptions 函数不重要的代码删除，剩余部分我们慢慢来看。</div><div class="notion-text notion-block-bff45b8f055c45da8890f52471a0ce0d">首先申明 extendsFrom 变量保存 child.extends，如果 extendsFrom 为真，递归调用 mergeOptions 进行属性拷贝，并且将 merge 结果保存到 parent 变量。</div><div class="notion-text notion-block-228eb941ba6841429ae729a323b89915">如果 child.mixins 为真，循环 mixins 数组，递归调用 mergeOptions 实现属性拷贝，仍旧将 merge 结果保存到 parent 变量。</div><div class="notion-text notion-block-4a88bccee41944abb3c58072ea2cde0b">接下来是关于 parent、child 的属性赋值：</div><div class="notion-text notion-block-71d6758243fa41d0b7aaf36519e0535b">申明 options 空对象，用来保存属性拷贝的结果，也作为递归调用 mergeOptions 的返回值。</div><div class="notion-text notion-block-26a8310056504c65b141f1986a4b08b4">这里首先会调用 for…in 对 parent 进行循环，在循环中不断调用 mergeField 函数。</div><div class="notion-text notion-block-683ae2b8b1f54279b8656f743d2970b8">接着调用 for…in 对 child 进行循环，这里有点不太一样，会调用 hasOwn 判断 parent 上是否有这个 key，如果没有再调用 mergeField 函数，这样避免了重复调用。</div><div class="notion-text notion-block-50cab76d35ee41019a2f619fe502e42e">那么这个 mergeField 函数到底是用来做什么的呢？</div><div class="notion-text notion-block-e2d530808ef6493c8f0977ac423130ce">mergeField 函数接收一个 key，首先会申明 strat 变量，如果 strats[key] 为真，就将 strats[key] 赋值给 strat。</div><div class="notion-text notion-block-9928f11208844464af6220cff5d09bd2">strats 其实就是 Object.create(null)，Object.create 用来创建一个新对象，strats 默认是调用 Object.create(null) 生成的空对象。</div><div class="notion-text notion-block-d49153fa0ba94c429206ca4ae3911308">顺便说一句，vue 也向外暴露了 Vue.config.optionMergeStrategies，可以实现自定义选项合并策略。</div><div class="notion-text notion-block-a63fc93639074c30937dfc78a23cdedb">如果 strats[key] 为假，这里会用 || 做穿透赋值，将 defaultStrat 默认函数赋值给 strat。</div><div class="notion-text notion-block-3093f46e66bb4461b7d548d272a563c8">defaultStrat 函数返回一个三元表达式，如果 childVal 为 undefined，返回 parentVal，否则返回 childVal，这里主要以 childVal 优先，这也是为什么有 component &gt; mixins &gt; extends 这样的优先级。</div><div class="notion-text notion-block-62d978df28894eecae78768f4fe23ba0">mergeField 函数最后会将调用 strat 的结果赋值给 options[key]。</div><div class="notion-text notion-block-381452002ace4ae6984f5b745a6d5e32">mergeOptions 函数最后会 merge 所有 options、 mixins、 extends，并将 options 对象返回，然后再去实例化 vue。</div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-63e0c8998a3b4dfcb4abb08046ec54f5" data-id="63e0c8998a3b4dfcb4abb08046ec54f5"><span><div id="63e0c8998a3b4dfcb4abb08046ec54f5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#63e0c8998a3b4dfcb4abb08046ec54f5" title="钩子函数的合并"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">钩子函数的合并</span></span></h3><div class="notion-text notion-block-3da6721f10984f61824f1e2a9f1b6208">我们来看看钩子函数是怎么进行合并的。</div><div class="notion-text notion-block-2642430931b0449c86b4e485b5904272">循环 LIFECYCLE_HOOKS 数组，不断调用 mergeHook 函数，将返回值赋值给 strats[hook]。</div><div class="notion-text notion-block-c7d01acaf7f04770abd37ff0342fc502">LIFECYCLE_HOOKS 就是申明的 vue 所有的钩子函数字符串。</div><div class="notion-text notion-block-a83eb23b1e844a699952cb3b17d10b41">mergeHook 函数会返回 3 层嵌套的三元表达式。</div><div class="notion-text notion-block-5b84c105225442488c6bb264e8c3e788">第一层，如果 childVal 为真，返回第二层三元表达式，如果为假，返回 parentVal。</div><div class="notion-text notion-block-f07e4b00dc7948fbab334bec0ac19670">第二层，如果 parentVal 为真，返回 parentVal 和 childVal 合并后的数组，如果 parentVal 为假，返回第三层三元表达式。</div><div class="notion-text notion-block-ea623a064db34fd3a2fe8f5036f218d3">第三层，如果 childVal 是数组，返回 childVal，否则将 childVal 包装成数组返回。</div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-1a84e889cf324a66aa5ee42b4fed9c7e" data-id="1a84e889cf324a66aa5ee42b4fed9c7e"><span><div id="1a84e889cf324a66aa5ee42b4fed9c7e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1a84e889cf324a66aa5ee42b4fed9c7e" title="项目实践"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">项目实践</span></span></h3><div class="notion-text notion-block-9ab69f12c55d47afbc0a51859aae13dd">使用 vue 的小伙伴们，当然也少不了在项目中使用 element-ui。比如使用 Table 表格的时候，免不了申明 tableData、total、pageSize 一些 Table 表格、Pagination 分页需要的参数。</div><div class="notion-text notion-block-800bdf28ec9e480a842c4432b672e5df">我们可以将重复的 data、methods 写在一个 tableMixin 中。</div><div class="notion-text notion-block-f469f521377846bbb3f28875e24bd896">当我们需要使用时直接引入即可：</div><div class="notion-text notion-block-2a7ebabdc204435eb47b2d205c790004">我们在组件内会重新申明 searchData 方法。类似这种 methods 对象形式的 key，如果 key 相同，组件内的 key 会覆盖 tableMixin 中的 key。</div><div class="notion-text notion-block-420cfc6d3b76445aa8d85d118c65dab6">当然我们也可以在 mixins 中嵌套 mixins，申明 axiosMixin:</div><div class="notion-text notion-block-4f3e51614cb3467f8456e7a4c61e5241">引入 axiosMixin：</div><div class="notion-text notion-block-d93c7d82502b48b986f6ca96d75d0a7d">在 axios 中，我们可以预先处理 axios 的 success、error 的后续调用，是不是少写了很多代码。</div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-a8811105b87c46f2ac681ba76c702841" data-id="a8811105b87c46f2ac681ba76c702841"><span><div id="a8811105b87c46f2ac681ba76c702841" class="notion-header-anchor"></div><a class="notion-hash-link" href="#a8811105b87c46f2ac681ba76c702841" title="extend"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">extend</span></span></h3><div class="notion-text notion-block-0d944f3cd8214fb1b17e81762f3717be">顺便讲一下 extend，与 mixins 相似，只能传入一个 options 对象，并且 mixins 的优先级比较高，会覆盖 extend 同名 key 值。</div><div class="notion-text notion-block-d6be0edc8a81435db79f24e8acdbd7b5">在 mergeOptions 函数中，会先对 extends 进行属性拷贝，然后再对 mixin 进行拷贝，在调用 mergeField 函数的时候会优先取 child 的 key。</div><div class="notion-text notion-block-ff5596da05bd4df596eacb0833def226">虽然 extends 的同名 key 会被 mixins 的覆盖，但是 extends 是优先执行的。</div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-b9e4937ad03f452e878a04eaafade375" data-id="b9e4937ad03f452e878a04eaafade375"><span><div id="b9e4937ad03f452e878a04eaafade375" class="notion-header-anchor"></div><a class="notion-hash-link" href="#b9e4937ad03f452e878a04eaafade375" title="总结"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">总结</span></span></h3><div class="notion-text notion-block-5780a99a198741f9b5d0cf07b29744a3">注意一下 vue 中 mixins 的优先级，component &gt; mixins &gt; extends。</div><div class="notion-text notion-block-b83d4b0ac5e04cd6b99d2322a4b845ec">我们暂且将 mixins 称作是组件模块化，灵活运用组件模块化，可以将组件内的重复代码提取出来，实现代码复用，也使我们的代码更加清晰，效率也大大提高。</div><div class="notion-text notion-block-461e8fddfb444b17aee23ba6c7c8ac48">当然，mixins 还有更加神奇的操作等你去探索。</div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[vue nextTick 源码浅析]]></title>
            <link>https://zxs-1024.cn/article/vue-next-tick</link>
            <guid>https://zxs-1024.cn/article/vue-next-tick</guid>
            <pubDate>Fri, 02 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[在下次 DOM 更新循环结束之后执行延迟回调。在修改数据之后立即使用这个方法，获取更新后的 DOM。]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-517ab873c510468b8ca0507c28493aa1"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-dd18521162be42dd9479d15818d1094f" data-id="dd18521162be42dd9479d15818d1094f"><span><div id="dd18521162be42dd9479d15818d1094f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#dd18521162be42dd9479d15818d1094f" title="vue nextTick 源码浅析"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">vue nextTick 源码浅析</span></span></h2><div class="notion-text notion-block-6c85a83efa074214b429fc7fa4a33a67">在下次 DOM 更新循环结束之后执行延迟回调。在修改数据之后立即使用这个方法，获取更新后的 DOM。</div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-198e56d2889d43739a233cf19f1a98f6" data-id="198e56d2889d43739a233cf19f1a98f6"><span><div id="198e56d2889d43739a233cf19f1a98f6" class="notion-header-anchor"></div><a class="notion-hash-link" href="#198e56d2889d43739a233cf19f1a98f6" title="$nextTick 函数的注册"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">$nextTick 函数的注册</span></span></h3><div class="notion-text notion-block-bdc8dd0b4c0a43418d305f1db9b64904">在 renderMixin 函数中我们会为 Vue.prototype 添加 $nextTick 方法，在 core/instance/render.js 文件中：</div><div class="notion-text notion-block-8efd63514baf4ea2bde441df1d79a385">在 $nextTick 方法中会返回 nextTick 函数的调用，并且在调用时传入了 fn 回调函数和 this，也就是 vue 实例。</div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-39a1ccaf4e9c4a4b8f957f0ad8461029" data-id="39a1ccaf4e9c4a4b8f957f0ad8461029"><span><div id="39a1ccaf4e9c4a4b8f957f0ad8461029" class="notion-header-anchor"></div><a class="notion-hash-link" href="#39a1ccaf4e9c4a4b8f957f0ad8461029" title="nextTick 函数"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">nextTick 函数</span></span></h3><div class="notion-text notion-block-ce6ef7308c314635bb5d65e3b8943e6a">nextTick 函数申明在 src/core/util/next-tick.js 文件：</div><div class="notion-text notion-block-90d70ba9d01d46c99be174f03745353d">nextTick 函数接收两个参数，cb 回调函数、ctx 上下文环境，在 $nextTick 中传入的是 vue 实例。</div><div class="notion-text notion-block-92ccff2497d84cdd853b431daa2fa1c8">nextTick 函数首先会申明 _resolve 变量，如果当前环境支持 Promise，会将 resolve 赋值给 _resolve 变量。</div><div class="notion-text notion-block-34e3fce979b24592846ac164e9807200">每一次调用 nextTick 函数，都会往 callbacks 中 push 函数，在函数中会判断 cb 是否为真，如果为真也就是传入了回调函数，会尝试将调用 call 将 cb 的 this 指向传入的 ctx 上下文环境，如果报错，就调用 handleError 函数抛出异常。</div><div class="notion-text notion-block-7a540e1d39304a4b891a0fc792442577">如果 _resolve 为真，调用 _resolve 函数，并且将 ctx 传入。</div><div class="notion-text notion-block-867d8b35753045fe87ee7ad99b559941">我们接着往下看：</div><div class="notion-text notion-block-e10fa720efb24225b6a91af99da7a980">如果 !pending 为真，也就是当前并没有在进行 nextTick 更新，将 pending 赋值为 true，说明正在进行 nextTick 更新。这里会判断 useMacroTask 是否为真，这个 useMacroTask 是什么呢？</div><div class="notion-text notion-block-15e1dbf9a6f64fc8bf599d07ac3c7af0">useMacroTask 是在 next-tick.js 开头申明的变量，默认为 false，这里作者给出了详细的注释。</div><blockquote class="notion-quote notion-block-0a480171ac0e4b189db0c90859cf1fab"><div>在 Vue 2.4 之前都是使用的 microtasks，但是 microtasks 的优先级过高，在某些情况下可能会出现比事件冒泡更快的情况，但如果都使用 macrotasks 又可能会出现渲染的性能问题。所以在新版本中，会默认使用 microtasks，但在特殊情况下会使用 macrotasks，比如 v-on。</div></blockquote><div class="notion-text notion-block-601c919f0cbe42e089657fddb5240e1c">useMacroTask 默认为 false，这里会走 else 循环，优先调用 microTimerFunc 函数。</div><div class="notion-text notion-block-4e55f16af33f4e36a3e5bf0e02efb4a7">我们来看看 microTimerFunc 函数：</div><div class="notion-text notion-block-c0873dcfec114409b9a9c41fed78a5bc">microTimerFunc 变量会在 next-tick.js 开头申明，默认为 undefined。</div><div class="notion-text notion-block-ff530270c521459084b6a70e492917c2">这里会判断调用 typeof 判断 Promise 的类型是否是 undefined，并且调用 isNative 判断 Promise 是否是原生的函数。</div><div class="notion-text notion-block-deff97dfc43b4d9ba155307702cb7d43">判断原型的话会判断函数 toString 后是否有 native code 字符串。</div><div class="notion-text notion-block-2f790948e93841e7a61cb2e47d17b816">如果都为真，判断当前环境支持 Promise 函数，申明 p 变量保存 Promise.resolve()，p 就成了一个 立即 resolve 的 Promise 对象。</div><div class="notion-text notion-block-845e17ed41b94c9d8000c1ec64538d9f">接着将 microTimerFunc 赋值成一个函数，在函数中会调用 then 方法，并将 flushCallbacks 函数传入，flushCallbacks 会在下一次 microtask 的时候执行。</div><div class="notion-text notion-block-8a74b1a7747547718434f8b89ebb06d1">如果 isIOS 为真，也就是当前设备是 IOS，为了兼容 UIWebViews 中出现的一些问题，回调被推到 microtask，但 microtask 没有刷新，我们可以添加空 setTimeout 来强制刷新 microtask。</div><div class="notion-text notion-block-811c6b5efe474de3834d74e9ec371de5">如果当前环境不支持 Promise，采取降级处理，将 microTimerFunc 赋值成 macroTimerFunc，macroTimerFunc 会在 microTimerFunc 之前进行赋值。</div><div class="notion-text notion-block-e3be8487d7b74b7495508ec8b01c648b">首先会判断如果当前环境支持 setImmediate，采用 macroTimerFunc 处理 flushCallbacks 函数，如果当前环境支持 MessageChannel 采用 MessageChannel 处理 flushCallbacks 函数，如果都不支持采用 setTimeout 处理 flushCallbacks 函数，这样实现了优雅的降级处理。</div><div class="notion-text notion-block-3aa857eed74f434192aa3ec2e9354a83">在 macroTimerFunc 和 microTimerFunc 的回调函数中，都会调用 flushCallbacks 函数，我们来看一下具体实现：</div><div class="notion-text notion-block-5f2bce3271af4506bf8c76e41824fc54">flushCallbacks 函数首先会将 pending 置为 false，代表上一次的 nextTick 更新完毕。</div><div class="notion-text notion-block-f862c03559494696b73e8fed43e5f40e">这里会申明 copies 变量，采用 slice 赋值一份 callbacks 数组，然后将 callbacks 清空，这里采用了 slice 为了清空 callbacks 而不影响 copies 数组，callbacks.slice(0) 返回一个新的数组，是一个新的引用地址。</div><div class="notion-text notion-block-fcc2e8c72df7498e98a412ef2c7c3296">然后采用 for 循环，循环调用 copies 中的函数。</div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-34763b76ce3b4ef1b65b70273a614d20" data-id="34763b76ce3b4ef1b65b70273a614d20"><span><div id="34763b76ce3b4ef1b65b70273a614d20" class="notion-header-anchor"></div><a class="notion-hash-link" href="#34763b76ce3b4ef1b65b70273a614d20" title="withMacroTask"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">withMacroTask</span></span></h3><div class="notion-text notion-block-029f4e2aa9194ad0b4a00a91a631c4f4">在 next-tick.js 中，除了暴露了 nextTick 函数， 还暴露了 withMacroTask 函数：</div><div class="notion-text notion-block-efbeca9a6c7f49c09ed267d0f5e35f35">withMacroTask 返回传入的 fn 的 _withTask 函数，这里用了传统赋值，如果 fn._withTask 为真，返回 fn._withTask，否则将 fn._withTask 赋值成一个函数，这个函数会将 useMacroTask 置为 true，使用 apply 将 this 指向 null，并用 res 变量保存返回，接着讲 useMacroTask 恢复成 false，最后返回 res。 我们知道当 useMacroTask 为 true 的时候会使用 macroTimerFunc 作为事件循环，调用 withMacroTask 函数传入的 fn 会插入到 microTask 任务队列。</div><div class="notion-text notion-block-5b16fbad30834742bda5df2f7dfe0335">withMacroTask 在 src/platforms/web/runtime/modules/events.js 中的 add 函数被调用:</div><div class="notion-text notion-block-76eedf2d4d1b4d8c94a2d1d0e89ee1ab">add 函数主要用来添加事件监听。</div><div class="notion-text notion-block-59091101c05044058632ac1dc96f139c">而 add 函数在 updateDOMListeners 函数中调用 updateListeners 函数时作为参数传入。</div><div class="notion-text notion-block-1153bf4b66ca4dbfa6658a65d721dfcc">updateListeners 会被 updateComponentListeners、updateDOMListeners 函数调用。</div><table class="notion-simple-table notion-block-93ec7890d34f4bf687ed4d9022e5b76e"><tbody><tr class="notion-simple-table-row notion-block-272ab60d10774a70a752f0e3771efa0d"><td class="" style="width:120px"><div class="notion-simple-table-cell">updateComponentListeners</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">updateDOMListeners</div></td></tr><tr class="notion-simple-table-row notion-block-66cb53fb69fe4d21a66d721b1e9dc9a3"><td class="" style="width:120px"><div class="notion-simple-table-cell">initEvents updateChildComponent</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">create update</div></td></tr><tr class="notion-simple-table-row notion-block-32c6b014c0c148a7b5edffd8631549e0"><td class="" style="width:120px"><div class="notion-simple-table-cell">———- componentVNodeHooks.prepatch</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">createPatchFunction</div></td></tr><tr class="notion-simple-table-row notion-block-36a068f472c34772b34090b42977c878"><td class="" style="width:120px"><div class="notion-simple-table-cell">ㅤ</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Vue.prototype.<b>patch</b> = patch</div></td></tr><tr class="notion-simple-table-row notion-block-2bb5199cd0ec4f7191add67f2aa422d0"><td class="" style="width:120px"><div class="notion-simple-table-cell">ㅤ</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">beforeMount lifecycleMixin {$destroy, $destroy}</div></td></tr></tbody></table><div class="notion-text notion-block-13ebc511eb7540b3b76c85d6d79d27a2">向上查看调用链。</div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-c0dc8f1447a94c2798fa1b5b594026d8" data-id="c0dc8f1447a94c2798fa1b5b594026d8"><span><div id="c0dc8f1447a94c2798fa1b5b594026d8" class="notion-header-anchor"></div><a class="notion-hash-link" href="#c0dc8f1447a94c2798fa1b5b594026d8" title="nextTick 调用"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">nextTick 调用</span></span></h3><div class="notion-text notion-block-255e9bb7544c4631812006a85d3b60ac">html</div><div class="notion-text notion-block-3e9a78a7b4ba40d7949dec55fdc67c80">js</div><div class="notion-blank notion-block-a06190632fec4c13b5b40c142af55b50"> </div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[我的 2018]]></title>
            <link>https://zxs-1024.cn/article/2018</link>
            <guid>https://zxs-1024.cn/article/2018</guid>
            <pubDate>Mon, 31 Dec 2018 00:00:00 GMT</pubDate>
            <description><![CDATA[兜兜转转又是一年，2018 收获颇多，在这里稍微做一下总结。
2018 年初，本打算往杭州发展，年前就前往杭州面试，也拿了几份 offer，但是计划终究赶不上变化，年后还是留在了上海，入职了一家比较满意的公司，也开始沉淀一些东西。]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-33439fa7b56849eb8b0984f2c21b3105"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-d73b635d61e348e781444a8f40f55cf5" data-id="d73b635d61e348e781444a8f40f55cf5"><span><div id="d73b635d61e348e781444a8f40f55cf5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#d73b635d61e348e781444a8f40f55cf5" title="我的 2018"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">我的 2018</span></span></h2><div class="notion-text notion-block-38f64227077340b0884e8b1abe421d76">兜兜转转又是一年，2018 收获颇多，在这里稍微做一下总结。</div><div class="notion-text notion-block-d023ee404c9343d1a4c45354eebc9877">2018 年初，本打算往杭州发展，年前就前往杭州面试，也拿了几份 offer，但是计划终究赶不上变化，年后还是留在了上海，入职了一家比较满意的公司，也开始沉淀一些东西。</div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-efd602bc6e2349c689bef133db568db3" data-id="efd602bc6e2349c689bef133db568db3"><span><div id="efd602bc6e2349c689bef133db568db3" class="notion-header-anchor"></div><a class="notion-hash-link" href="#efd602bc6e2349c689bef133db568db3" title="回顾 2018"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">回顾 2018</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-3f2945bdd0c6483f9d4085245bb41057" data-id="3f2945bdd0c6483f9d4085245bb41057"><span><div id="3f2945bdd0c6483f9d4085245bb41057" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3f2945bdd0c6483f9d4085245bb41057" title="深入学习 vue、vuex、vue-router 源码"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">深入学习 vue、vuex、vue-router 源码</span></span></h4><div class="notion-text notion-block-71f7a6e1891a4b759cb61839d6cb7ddc">有些粗糙的过了一遍 vue 源码，也研究了 vuex、vue-router 的源码，对 vue 有了更加深入的了解。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-9d44dffc172d432d9d7de11280892463" data-id="9d44dffc172d432d9d7de11280892463"><span><div id="9d44dffc172d432d9d7de11280892463" class="notion-header-anchor"></div><a class="notion-hash-link" href="#9d44dffc172d432d9d7de11280892463" title="vuex 源码阅读笔记"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://github.com/zxs-1024/record/blob/master/vue/vuex.md">vuex 源码阅读笔记</a></span></span></h4><div class="notion-text notion-block-cf28c1b6b0bc42d6a3431e39108b01df"><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://sailor-1256168624.cos.ap-chengdu.myqcloud.com/blog/vuex.png">vuex 思维导图 原图</a></div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-60040128341c4c99ab27a6ea2245fa74"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://sailor-1256168624.cos.ap-chengdu.myqcloud.com/blog/vuex-mini.png" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-474ef13bda184fa2a7dc59906a767763">vuex 思维导图</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-913cb7cbd8024230a6adf6ad88a21627" data-id="913cb7cbd8024230a6adf6ad88a21627"><span><div id="913cb7cbd8024230a6adf6ad88a21627" class="notion-header-anchor"></div><a class="notion-hash-link" href="#913cb7cbd8024230a6adf6ad88a21627" title="阅读 vue-router 源码的一些注释"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://github.com/zxs-1024/vue-router/tree/dev/src">阅读 vue-router 源码的一些注释</a></span></span></h4><div class="notion-text notion-block-86ce7fa3553f445f960932e86af0b6dd"><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://sailor-1256168624.cos.ap-chengdu.myqcloud.com/blog/vue-router.png">vue-router 思维导图</a></div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-b0ae267b16b24c549bbde4c563b304e0"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://sailor-1256168624.cos.ap-chengdu.myqcloud.com/blog/vue-router-mini.png" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-847db9e4f4974990afd74996f61d4350">vue-router 思维导图 原图</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-ddca1711db37498cb3a047db169b69c2" data-id="ddca1711db37498cb3a047db169b69c2"><span><div id="ddca1711db37498cb3a047db169b69c2" class="notion-header-anchor"></div><a class="notion-hash-link" href="#ddca1711db37498cb3a047db169b69c2" title="关于 React 的学习"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">关于 React 的学习</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-d9a8d1baec39443893d03e493c3c0f75" data-id="d9a8d1baec39443893d03e493c3c0f75"><span><div id="d9a8d1baec39443893d03e493c3c0f75" class="notion-header-anchor"></div><a class="notion-hash-link" href="#d9a8d1baec39443893d03e493c3c0f75" title="React todo list"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://github.com/zxs-1024/react-todolist">React todo list</a></span></span></h4><div class="notion-text notion-block-37adcc6182234b0c82f04dbdb1325b0f">使用了 todolist 作为练手项目，期间重构了多个版本，主要有 redux 、dva 、rematch 版本，熟悉 react 、 jsx 语法，熟悉 redux 、dva 、rematch，以及项目构建。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-0b5b17c4e89b4573980696d470c2bfd0"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://sailor-1256168624.cos.ap-chengdu.myqcloud.com/todolist.jpg" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-2526eaaa9aab4a668005f34a534c6813">React todo list</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-9fc69b77f652445fabbb6d36bc56dc99" data-id="9fc69b77f652445fabbb6d36bc56dc99"><span><div id="9fc69b77f652445fabbb6d36bc56dc99" class="notion-header-anchor"></div><a class="notion-hash-link" href="#9fc69b77f652445fabbb6d36bc56dc99" title="bing-app"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://zhanghao-zhoushan.cn/bing-app/#/">bing-app</a></span></span></h4><div class="notion-text notion-block-a0c82f411f7f44fabe27140c82493faf">收集 Bing 每日精彩图片的网站，前端采用 React、后端采用 koa2 构建。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-73777078ec074f30a24aef2a48c6aa35"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://sailor-1256168624.cos.ap-chengdu.myqcloud.com/bing.jpg" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-df665bdd0eff4ed292908c10b821f011">Bing Image Collect</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-6d3991883071438c8372f015f33c6d9c" data-id="6d3991883071438c8372f015f33c6d9c"><span><div id="6d3991883071438c8372f015f33c6d9c" class="notion-header-anchor"></div><a class="notion-hash-link" href="#6d3991883071438c8372f015f33c6d9c" title="其他的"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">其他的</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-92a7cba0502f41499225d2fc65f77c1e" data-id="92a7cba0502f41499225d2fc65f77c1e"><span><div id="92a7cba0502f41499225d2fc65f77c1e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#92a7cba0502f41499225d2fc65f77c1e" title="📏 使用 ESLint 来管理你的 git commit 代码规范"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://github.com/zxs-1024/use-eslint-in-git-hooks">📏 使用 ESLint 来管理你的 git commit 代码规范</a></span></span></h4><div class="notion-text notion-block-d49a1ba7d397406587930acd8ed7fcd9">逐渐认识到代码质量的重要性，开始使用 ESLint 来管理你的代码规范。</div><div class="notion-text notion-block-e53775c440b14bb59a2300c2b07084c3">提交前强制校验，使用 husky，将约束命令放置在提交代码前检查。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-68d18b65938740598ba5c4b5aac46be5" data-id="68d18b65938740598ba5c4b5aac46be5"><span><div id="68d18b65938740598ba5c4b5aac46be5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#68d18b65938740598ba5c4b5aac46be5" title="📜 帮助你创建你的项目模板文件"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://github.com/zxs-1024/create-project-template">📜 帮助你创建你的项目模板文件</a></span></span></h4><div class="notion-text notion-block-cd51dfe1d3f6404a8043fe86190848d2">一个 npm 包，用来帮助我建立项目模板文件。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-02a717c048af410eb5442dc9300b79cc" data-id="02a717c048af410eb5442dc9300b79cc"><span><div id="02a717c048af410eb5442dc9300b79cc" class="notion-header-anchor"></div><a class="notion-hash-link" href="#02a717c048af410eb5442dc9300b79cc" title="Lodash 源码解析"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://github.com/zxs-1024/record/issues/15">Lodash 源码解析</a></span></span></h4><div class="notion-text notion-block-4e11f11f057c44fead9d7aa131c3c7f2">阅读 Lodash 源码， Get 到很多新技能。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-bca94d9604754697b512ff656cc683f6" data-id="bca94d9604754697b512ff656cc683f6"><span><div id="bca94d9604754697b512ff656cc683f6" class="notion-header-anchor"></div><a class="notion-hash-link" href="#bca94d9604754697b512ff656cc683f6" title="Learn Advanced Vue.js Features with the Creator of Vue.js, Evan You!"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://frontendmasters.com/courses/advanced-vue/">Learn Advanced Vue.js Features with the Creator of Vue.js, Evan You!</a></span></span></h4><div class="notion-text notion-block-0407793d94c44d928f0bf987f29f9ee2">在 <a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://frontendmasters.com/">Frontend Masters</a> 中有很大师级别的课程，这个是尤大大的课程，学习高级 Vue.js 功能。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-c1e3a15aca814fbd84f8925423311795" data-id="c1e3a15aca814fbd84f8925423311795"><span><div id="c1e3a15aca814fbd84f8925423311795" class="notion-header-anchor"></div><a class="notion-hash-link" href="#c1e3a15aca814fbd84f8925423311795" title="2018 看过的书"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2018 看过的书</span></span></h4><ul class="notion-list notion-list-disc notion-block-3fed7d1014704d89b47b54d123afc5bd"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://book.douban.com/subject/30143702/">JavaScript 忍者秘籍（第 2 版）</a></li></ul><ul class="notion-list notion-list-disc notion-block-4596f3bba9b44d03a8e191b819ac834f"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://book.douban.com/subject/5362856/">高性能 JavaScript</a></li></ul><ul class="notion-list notion-list-disc notion-block-1f9aa28e28944ee3aeb2e6ac16d7d5e4"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://book.douban.com/subject/27072230/">深入理解 ES6</a></li></ul><ul class="notion-list notion-list-disc notion-block-9cd13431f99243cda5bf569cc1c26b2a"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://book.douban.com/subject/21792530">编写可维护的 JavaScript</a></li></ul><ul class="notion-list notion-list-disc notion-block-e7f53d857e054bf3b815de2cf52dc961"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://legacy.gitbook.com/book/llh911001/mostly-adequate-guide-chinese/details">JS 函数式编程指南</a></li></ul><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-8c3e7fda15524daeadcf9e00f6f8c5d7" data-id="8c3e7fda15524daeadcf9e00f6f8c5d7"><span><div id="8c3e7fda15524daeadcf9e00f6f8c5d7" class="notion-header-anchor"></div><a class="notion-hash-link" href="#8c3e7fda15524daeadcf9e00f6f8c5d7" title="2018 文章收集"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2018 文章收集</span></span></h4><ul class="notion-list notion-list-disc notion-block-8f9f16801b32448dbb1b1e2bf2c9cacb"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://github.com/zxs-1024/blog/blob/master/content/%E5%89%8D%E7%AB%AF%E6%96%87%E7%AB%A0%E9%9B%86%E9%94%A6/2017.md">2017 Collect</a></li></ul><ul class="notion-list notion-list-disc notion-block-718a90fda047476f8cb1651292daea38"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://github.com/zxs-1024/blog/blob/master/content/%E5%89%8D%E7%AB%AF%E6%96%87%E7%AB%A0%E9%9B%86%E9%94%A6/2018.md">2018 Collect</a></li></ul><ul class="notion-list notion-list-disc notion-block-19835a87609d44008602dfd6ce66b2d5"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://github.com/zxs-1024/blog/blob/master/content/%E5%89%8D%E7%AB%AF%E6%96%87%E7%AB%A0%E9%9B%86%E9%94%A6/2019.md">2019 Collect</a></li></ul><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-9437126aea824a3e8a4dc42fb342066b" data-id="9437126aea824a3e8a4dc42fb342066b"><span><div id="9437126aea824a3e8a4dc42fb342066b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#9437126aea824a3e8a4dc42fb342066b" title="你好，2019 ！"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">你好，2019 ！</span></span></h3><div class="notion-text notion-block-ae3d3c1ac29141b7a68b1d5c8be80e64">2019 计划：</div><ul class="notion-list notion-list-disc notion-block-efd9b187cfed467a93a7a76b02e16dca"><li>要增加个人技术输出。</li></ul><ul class="notion-list notion-list-disc notion-block-70f786a4364047f89ad0531db11666d3"><li>向全栈触发，学习关于服务器端的知识。</li></ul><ul class="notion-list notion-list-disc notion-block-f1dfd5eebbcd42008820f37c88dbee4a"><li>深入学习 JS 底层，扎实基础。</li></ul><ul class="notion-list notion-list-disc notion-block-cf53d463a4524b21a7f9f1dc49914a65"><li>增强英语阅读能力。</li></ul><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-5333c13214404719b54330d07de5aae6" data-id="5333c13214404719b54330d07de5aae6"><span><div id="5333c13214404719b54330d07de5aae6" class="notion-header-anchor"></div><a class="notion-hash-link" href="#5333c13214404719b54330d07de5aae6" title="2019 想要了解的"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2019 想要了解的</span></span></h4><ul class="notion-list notion-list-disc notion-block-aae0c45e2bc149598502d9db16c58fae"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://github.com/facebook/immutable-js/">immutable-js</a> 持久化数据结构</li></ul><ul class="notion-list notion-list-disc notion-block-f5e66dd956024134b85df577cd89d3a2"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://github.com/ReactiveX/rxjs/">RxJS</a> 使用 Observables 的响应式编程</li></ul><ul class="notion-list notion-list-disc notion-block-14700907b0014332a009dedfd7e3fc7c"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://electronjs.org/">Electron</a> 跨平台的桌面应用</li></ul><ul class="notion-list notion-list-disc notion-block-9f8146431afa41f2a3039c46f8add94f"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://flutterchina.club/">Flutter</a> 谷歌的移动 UI 框架</li></ul><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-60758793f17649b782c85fe6cd73d31a" data-id="60758793f17649b782c85fe6cd73d31a"><span><div id="60758793f17649b782c85fe6cd73d31a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#60758793f17649b782c85fe6cd73d31a" title="2019 要看的书"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2019 要看的书</span></span></h4><ul class="notion-list notion-list-disc notion-block-fb4fd60b014242d1b62266bb890ed025"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://book.douban.com/subject/30247892/">Node.js：来一打 C++ 扩展</a></li></ul><ul class="notion-list notion-list-disc notion-block-a14b2e314431449f8bff4fbcf5a10fdf"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://book.douban.com/subject/27008702/">剑指 Offer：名企面试官精讲典型编程题（第 2 版）</a></li></ul><ul class="notion-list notion-list-disc notion-block-af38ef91f3eb463fbb4684c00ebbea06"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://book.douban.com/subject/25910556/">WebKit 技术内幕</a></li></ul><ul class="notion-list notion-list-disc notion-block-08b540da9df04a5585493a96cfcd256a"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://book.douban.com/subject/30437260/">大型网站性能优化实战</a></li></ul><ul class="notion-list notion-list-disc notion-block-f1fe3253828144e08772f285d305559b"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://book.douban.com/subject/26382780/">JavaScript 设计模式与开发实践</a></li></ul><ul class="notion-list notion-list-disc notion-block-3bb55761c5224ac9a5e0d0bd9fe6a6a4"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://github.com/trekhleb/javascript-algorithms/blob/master/README.zh-CN.md">GitHub JavaScript 算法与数据结构</a></li></ul><ul class="notion-list notion-list-disc notion-block-9f4680140bae44f5a9daa64ef097253a"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://www.amazon.com/How-JavaScript-Works-Douglas-Crockford/dp/1949815013">How JavaScript Works</a></li></ul><ul class="notion-list notion-list-disc notion-block-d85cd9baa062460bbab8fd338423ea12"><li>期待 深入浅出 Node.js 第二版</li></ul></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Vuex 是什么？]]></title>
            <link>https://zxs-1024.cn/article/vuex-init</link>
            <guid>https://zxs-1024.cn/article/vuex-init</guid>
            <pubDate>Fri, 02 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[Vuex 是一个专为 Vue.js 应用程序开发的状态管理模式。它采用集中式存储管理应用的所有组件的状态，并以相应的规则保证状态以一种可预测的方式发生变化。]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-c9f738c6a8194e8a8ec3fad737a0ed92"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-eafc5f1966384fe2bfc231f445fd7877" data-id="eafc5f1966384fe2bfc231f445fd7877"><span><div id="eafc5f1966384fe2bfc231f445fd7877" class="notion-header-anchor"></div><a class="notion-hash-link" href="#eafc5f1966384fe2bfc231f445fd7877" title="Vuex 是什么？"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Vuex 是什么？</span></span></h3><div class="notion-text notion-block-38caf98a576b43899cde3d9d900d36c4"><code class="notion-inline-code">Vuex</code> 是一个专为 <code class="notion-inline-code">Vue.js</code> 应用程序开发的状态管理模式。它采用集中式存储管理应用的所有组件的状态，并以相应的规则保证状态以一种可预测的方式发生变化。</div><blockquote class="notion-quote notion-block-5e05b553bb2f4b02ba5dc6fe9b307916"><div>阅读 vuex 源码的思维导图:</div></blockquote><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-779a6dd84581412f9b4d6871f3248b80"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img src="https://sailor-1256168624.cos.ap-chengdu.myqcloud.com/blog/vuex-mini.png" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-22145e243a9a4295a8da9c7cd392a04c">阅读 vuex 源码的思维导图</div><div class="notion-text notion-block-b7c4ce71cb4a4786b4e25a50912183af"><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://vuex.vuejs.org/zh/">vuex 的文档</a> 对辅助看源码有不小的帮助，不妨在看源码之前仔细地撸一遍文档。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-38e53f0c12aa4394b2ef8386b78f86bc" data-id="38e53f0c12aa4394b2ef8386b78f86bc"><span><div id="38e53f0c12aa4394b2ef8386b78f86bc" class="notion-header-anchor"></div><a class="notion-hash-link" href="#38e53f0c12aa4394b2ef8386b78f86bc" title="带着问题去看源码"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">带着问题去看源码</span></span></h3><ul class="notion-list notion-list-disc notion-block-3c0001b43d0643b6af2355f9597208ea"><li>global event bus 有何缺陷</li></ul><ul class="notion-list notion-list-disc notion-block-cdeeb8e9ecd848e9871f21c40328f089"><li>$store 如何注入到所有子组件</li></ul><ul class="notion-list notion-list-disc notion-block-e9893a32caad4645b3f60924788b4a02"><li>mapState 实现</li></ul><ul class="notion-list notion-list-disc notion-block-8426e11de1a74c6ba9842effef8b67c2"><li>mapGetter 如何映射</li></ul><ul class="notion-list notion-list-disc notion-block-cddf9cd6fe9246788cfaca8cca7b3a31"><li>Mutation 同步 &amp;&amp; Action 异步</li></ul><ul class="notion-list notion-list-disc notion-block-87dfb46024554715a3977609a0f5a1a7"><li>dispatch 方法实现</li></ul><ul class="notion-list notion-list-disc notion-block-407faffb884d4c74a37ef45b9bec0d72"><li>module 分割实现 &amp;&amp; 局部状态 namespaced</li></ul><ul class="notion-list notion-list-disc notion-block-3983cd3903754cb28542fe406eedc9d4"><li>如何调用 vue-devtools</li></ul><ul class="notion-list notion-list-disc notion-block-6a0da969d9e347098b708a8753fc0003"><li>内置 logger 插件实现</li></ul><ul class="notion-list notion-list-disc notion-block-ef4d320406a34a9f98a726a627f2842f"><li>hotUpdate</li></ul><ul class="notion-list notion-list-disc notion-block-b829112b508142d3bf21c035d681ab1c"><li>时间穿梭功能实现</li></ul><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-e510115d56084d60a266f9b95122ce81" data-id="e510115d56084d60a266f9b95122ce81"><span><div id="e510115d56084d60a266f9b95122ce81" class="notion-header-anchor"></div><a class="notion-hash-link" href="#e510115d56084d60a266f9b95122ce81" title="目录"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">目录</span></span></h3><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-8f7bebab361e4d5f98f0c421b104cbbc" data-id="8f7bebab361e4d5f98f0c421b104cbbc"><span><div id="8f7bebab361e4d5f98f0c421b104cbbc" class="notion-header-anchor"></div><a class="notion-hash-link" href="#8f7bebab361e4d5f98f0c421b104cbbc" title="入口文件"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">入口文件</span></span></h3><div class="notion-text notion-block-d35bf3861a6d4946a51da89b977f91af">vuex 的入口文件在 <code class="notion-inline-code">src/index.js</code></div><div class="notion-text notion-block-e722fce4632c4080a52e29323255ff20">引入了 <code class="notion-inline-code">Store</code> 、<code class="notion-inline-code">install</code> 和一些辅助工具函数，将引入的变量组装成一个对象向外暴露。当我们在项目中引入 <code class="notion-inline-code">import Vuex from &#x27;vuex&#x27;</code> 的之后， <code class="notion-inline-code">Vuex</code> 就是这个组装后默认导出的对象了。</div><div class="notion-text notion-block-c98484635c0c43d387ae7ca27d6d3860">当然我们也可以通过解构的方式。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-d7e123ca6679406f8a6a06c8212cc2a6" data-id="d7e123ca6679406f8a6a06c8212cc2a6"><span><div id="d7e123ca6679406f8a6a06c8212cc2a6" class="notion-header-anchor"></div><a class="notion-hash-link" href="#d7e123ca6679406f8a6a06c8212cc2a6" title="install 方法"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">install 方法</span></span></h3><div class="notion-text notion-block-416ef91061114b8e960c109ee17b0c4a">来看一下 <code class="notion-inline-code">install</code> 方法，在 <code class="notion-inline-code">src/store.js</code> 。</div><div class="notion-text notion-block-8bb1f67da46042f6b587a86cb8f650c3">install 函数首先判断变量 <code class="notion-inline-code">Vue</code> (<code class="notion-inline-code">store.js</code> 顶部申明的变量) 是否与传入 <code class="notion-inline-code">_Vue</code> 全等，如果全等并且在非生产环境，抛出异常。</div><div class="notion-text notion-block-6cd0a93cba094833bc396f2a9d515286">随后将传入的 <code class="notion-inline-code">_Vue</code> 赋值给 <code class="notion-inline-code">Vue</code>，这里主要是为了避免重复安装。</div><div class="notion-text notion-block-42ee67329248426cbebdc667a42b748c">然后调用引入的 <code class="notion-inline-code">applyMixin</code> 方法，并将 <code class="notion-inline-code">Vue</code> 作为参数传入。</div><div class="notion-text notion-block-80f2989ff9b84ba0a348c58056e832cb"><code class="notion-inline-code">applyMixin</code> 在 <code class="notion-inline-code">src/mixin.js</code> 作为默认方法导出：</div><div class="notion-text notion-block-51d779f6d9f048048b27b7fd00f013b1">取出传入 <code class="notion-inline-code">Vue</code> 的 静态属性 <code class="notion-inline-code">version</code> 做不同处理。</div><div class="notion-text notion-block-40817263ed914b44a9ec62b358012800">2.0 采用 <code class="notion-inline-code">mixin</code> 将 <code class="notion-inline-code">vuexInit</code> 合并到 <code class="notion-inline-code">beforeCreate</code> 生命周期钩子。</div><div class="notion-text notion-block-5b89fa2e651a4851876917c1e0fbcb7e">1.0 重写 <code class="notion-inline-code">_init</code> 方法 将 <code class="notion-inline-code">vuexInit</code> 合并到 <code class="notion-inline-code">_init</code> 方法中。</div><div class="notion-text notion-block-8b37c4966f7842a4957148504f55d7a6">在 <code class="notion-inline-code">vuexInit</code> 方法中，首先判断如果有 <code class="notion-inline-code">options.store</code> 说明是 <code class="notion-inline-code">root</code> 节点，并且判断 <code class="notion-inline-code">store</code> 是 <code class="notion-inline-code">function</code> 就执行将函数返回值赋值给 <code class="notion-inline-code">this.$store</code> ，否则 <code class="notion-inline-code">options.store</code> 直接赋值。 然后判断有父节点，并且父节点有 <code class="notion-inline-code">$store</code>, 就将父节点的 <code class="notion-inline-code">$store</code> 赋值给 <code class="notion-inline-code">this.$store</code> ，这样就保证只有一个全局的 <code class="notion-inline-code">$store</code> 变量。</div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ webpack HMR]]></title>
            <link>https://zxs-1024.cn/article/webpack-hmr</link>
            <guid>https://zxs-1024.cn/article/webpack-hmr</guid>
            <pubDate>Mon, 06 Sep 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[和组内同学做过的一个关于 webpack 热更新实现的分享。]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-193f4825b650443880db80ed62669309"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-text notion-block-201e4b6c0a434082a5aa69197533386c">和组内同学做过的一个关于 webpack 热更新实现的分享。</div><blockquote class="notion-quote notion-block-9cc8372cb7664bfc92c226a1ca78a108"><div>具体 PPT 可到 slides 观看</div></blockquote><div class="notion-row"><a target="_blank" rel="noopener noreferrer" class="notion-bookmark notion-block-81bc6903576d49cb9e0d012cb89d3bf3" href="https://slides.com/hao-zhang/deck-57dcb4/fullscreen"><div><div class="notion-bookmark-title">Webpack HMR</div><div class="notion-bookmark-description">A presentation created with Slides.</div><div class="notion-bookmark-link"><div class="notion-bookmark-link-icon"><img src="https://slides.com/favicon.ico" alt="Webpack HMR" loading="lazy" decoding="async"/></div><div class="notion-bookmark-link-text">https://slides.com/hao-zhang/deck-57dcb4/fullscreen</div></div></div><div class="notion-bookmark-image"><img style="object-fit:cover" src="https://media.slid.es/thumbnails/ce1ede93bcb7829ef58962b5ea1cc55f/thumb.jpg?1692604804" alt="Webpack HMR" loading="lazy" decoding="async"/></div></a></div><h4 class="notion-h notion-h3 notion-h-indent-0 notion-block-763be30d387a41b6a6ad37755f6ffcab" data-id="763be30d387a41b6a6ad37755f6ffcab"><span><div id="763be30d387a41b6a6ad37755f6ffcab" class="notion-header-anchor"></div><a class="notion-hash-link" href="#763be30d387a41b6a6ad37755f6ffcab" title="什么是 HMR ?"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>什么是 HMR ?</b></span></span></h4><ul class="notion-list notion-list-disc notion-block-295421dafb8848779708b002b0ada5ef"><li><b>hot module replacement(更换)</b></li></ul><ul class="notion-list notion-list-disc notion-block-a47f95710cda43f8ab9e93749ed295d5"><li><b>无需刷新浏览器</b></li></ul><ul class="notion-list notion-list-disc notion-block-75b8643faedf4fa3917c4fe420709591"><li><b>运行时更新模块</b></li></ul><ul class="notion-list notion-list-disc notion-block-8f6212a3d1524cb6bbd4f24549bc7ef3"><li><b>保留更新前的应用程序状态</b></li></ul><h4 class="notion-h notion-h3 notion-h-indent-0 notion-block-87a9e62df7144b69bae0b25d7651e20b" data-id="87a9e62df7144b69bae0b25d7651e20b"><span><div id="87a9e62df7144b69bae0b25d7651e20b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#87a9e62df7144b69bae0b25d7651e20b" title="热更新的应用"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>热更新的应用</b></span></span></h4><ul class="notion-list notion-list-disc notion-block-04ec1a5068e64310b188dd0c9c86e846"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://github.com/vuejs/vue-hot-reload-api"><b>vue-hot-reload-api</b></a></li></ul><ul class="notion-list notion-list-disc notion-block-45b4ca8df0ab4cb9bc846d43250b9b85"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://github.com/gaearon/react-hot-loader"><b>React Hot Loader</b></a></li></ul><ul class="notion-list notion-list-disc notion-block-d88a2c1b23fc4de08636f725d3c8599f"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://github.com/facebook/react/tree/main/packages/react-refresh"><b>react-refresh</b></a></li></ul><h4 class="notion-h notion-h3 notion-h-indent-0 notion-block-d9ae596f64b74c5ea384f8e2b5e8654f" data-id="d9ae596f64b74c5ea384f8e2b5e8654f"><span><div id="d9ae596f64b74c5ea384f8e2b5e8654f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#d9ae596f64b74c5ea384f8e2b5e8654f" title="初始化"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>初始化</b></span></span></h4><ul class="notion-list notion-list-disc notion-block-b26a26dd689a420498bd18e6bcb37b3a"><li><b>服务是怎么启动？</b></li></ul><ul class="notion-list notion-list-disc notion-block-bd4336ed986a4b7f88ddecb4a6be53d5"><li><b>bundle.js 注入了很多代码</b></li></ul><ul class="notion-list notion-list-disc notion-block-d6643a41c2064dd2abf54b55a9b42881"><li><b>websocket 如何建立连接？</b></li></ul><ul class="notion-list notion-list-disc notion-block-46beb8ab008e45cda2bcb5d4209369a3"><li><b>接受四个消息做了什么？</b></li></ul><h4 class="notion-h notion-h3 notion-h-indent-0 notion-block-9118b561d0dc4ba8b426bd3781e4b7b3" data-id="9118b561d0dc4ba8b426bd3781e4b7b3"><span><div id="9118b561d0dc4ba8b426bd3781e4b7b3" class="notion-header-anchor"></div><a class="notion-hash-link" href="#9118b561d0dc4ba8b426bd3781e4b7b3" title="HMR 的实现"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>HMR 的实现</b></span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-0 notion-block-dfb29b152cd244be8db2ab160211ac4a" data-id="dfb29b152cd244be8db2ab160211ac4a"><span><div id="dfb29b152cd244be8db2ab160211ac4a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#dfb29b152cd244be8db2ab160211ac4a" title="官方文档"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">官方文档</span></span></h4><ul class="notion-list notion-list-disc notion-block-003afe06c8fb4a009809f467a6ed452e"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://webpack.docschina.org/api/hot-module-replacement/">Hot Module Replacement(更换) | webpack 中文文档</a></li></ul><ul class="notion-list notion-list-disc notion-block-bfb7b2faf0f74b879079450b3ed226ee"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://webpack.docschina.org/concepts/hot-module-replacement/">模块热替换(hot module replacement(更换)) | webpack 中文文档</a></li></ul><ul class="notion-list notion-list-disc notion-block-f555d0d7fedd47c8b73a252876424d2b"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://webpack.docschina.org/guides/hot-module-replacement/">模块热替换 | webpack 中文文档</a></li></ul><h4 class="notion-h notion-h3 notion-h-indent-0 notion-block-27c1088743e446878c7cdf0dfa0c06a5" data-id="27c1088743e446878c7cdf0dfa0c06a5"><span><div id="27c1088743e446878c7cdf0dfa0c06a5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#27c1088743e446878c7cdf0dfa0c06a5" title="参考文章"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">参考文章</span></span></h4><ul class="notion-list notion-list-disc notion-block-b3942c7551034a468ff00cc8c381305d"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://segmentfault.com/a/1190000023534941">一分钟用上热更新 React Fast Refresh（react-refresh）</a></li></ul><ul class="notion-list notion-list-disc notion-block-92c95f217de7495dbe2c145c75e75f50"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://github.com/Jocs/jocs.github.io/issues/15">Webpack Hot Module Replacement(更换) 的原理解析</a></li></ul><ul class="notion-list notion-list-disc notion-block-581691b9f00543539c49b50d6ac5925c"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://blog.csdn.net/chern1992/article/details/106893227/">轻松理解webpack热更新原理</a></li></ul><ul class="notion-list notion-list-disc notion-block-3ef705c24fa6406684cdcd1eea6b07be"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://juejin.cn/post/6979058369352957960">三千字基于 HMR 插件解析 Webpack 源码</a></li></ul><ul class="notion-list notion-list-disc notion-block-d7d7ab16a29c4d8d9e56b9e44ceb00e9"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://juejin.cn/post/6966422095274180639">[探索] Webpack DevServer和HMR原理</a></li></ul><ul class="notion-list notion-list-disc notion-block-553efae81dd14998b9a83b3033f6536c"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://github.com/Xia-Ao/Notes/blob/master/PrjConstruct/Webpack/03-webpack%E7%83%AD%E6%9B%B4%E6%96%B0%E5%8E%9F%E7%90%86.md">webpack热更新原理</a></li></ul></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[小程序拾遗]]></title>
            <link>https://zxs-1024.cn/article/56ea452f-468f-41e7-9a1a-544e8c7ef420</link>
            <guid>https://zxs-1024.cn/article/56ea452f-468f-41e7-9a1a-544e8c7ef420</guid>
            <pubDate>Fri, 02 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[小程序拾遗]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-56ea452f468f41e79a1a544e8c7ef420"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1507e8f951eb4c3f9dc2f5ca322e2ac1" data-id="1507e8f951eb4c3f9dc2f5ca322e2ac1"><span><div id="1507e8f951eb4c3f9dc2f5ca322e2ac1" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1507e8f951eb4c3f9dc2f5ca322e2ac1" title="跳转微信公众号"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">跳转微信公众号</span></span></h3><div class="notion-text notion-block-18c6008856724b5fbb2724000e46f174">登陆微信公众平台，F12 打开浏览器控制台 console 输入</div><div class="notion-text notion-block-c69e8094e8e74aa9895c503796dd4a23">https://mp.weixin.qq.com/mp/profile_ext?action=home&amp;__biz=上方步骤输出的内容#wechat_redirect</div><div class="notion-text notion-block-b2fd55a8220248138c14af5331cbfe16">该链接可直接在微信内进入公众号关注页（非公众号客户端不支持）。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-e96d333b8b3947dc9d39384ad8f11142" data-id="e96d333b8b3947dc9d39384ad8f11142"><span><div id="e96d333b8b3947dc9d39384ad8f11142" class="notion-header-anchor"></div><a class="notion-hash-link" href="#e96d333b8b3947dc9d39384ad8f11142" title="动态加载网络字体"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">动态加载网络字体</span></span></h3><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-8d175916337642999fc48656389f6827" data-id="8d175916337642999fc48656389f6827"><span><div id="8d175916337642999fc48656389f6827" class="notion-header-anchor"></div><a class="notion-hash-link" href="#8d175916337642999fc48656389f6827" title="动态插入"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">动态插入</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-fbcf3c76e4234738ae955506b5351c20" data-id="fbcf3c76e4234738ae955506b5351c20"><span><div id="fbcf3c76e4234738ae955506b5351c20" class="notion-header-anchor"></div><a class="notion-hash-link" href="#fbcf3c76e4234738ae955506b5351c20" title="React 18 之前的版本"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">React 18 之前的版本</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-360a24ae591b42a18ad8813f8448366d" data-id="360a24ae591b42a18ad8813f8448366d"><span><div id="360a24ae591b42a18ad8813f8448366d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#360a24ae591b42a18ad8813f8448366d" title="React 18"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">React 18</span></span></h4><div class="notion-text notion-block-86171c02f33244efb0a8a79ec0d133c6"><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://reactjs.org/link/switch-to-createroot">https://reactjs.org/link/switch-to-createroot</a></div><blockquote class="notion-quote notion-block-74d3fc4db7cf48bbb1a8bcd856465237"><div>Warning: ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it&#x27;s running React 17. Learn more: https://reactjs.org/link/switch-to-createroot</div></blockquote><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-ac06174493544fa0b00d4a0b7461ca15" data-id="ac06174493544fa0b00d4a0b7461ca15"><span><div id="ac06174493544fa0b00d4a0b7461ca15" class="notion-header-anchor"></div><a class="notion-hash-link" href="#ac06174493544fa0b00d4a0b7461ca15" title="海报绘制"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">海报绘制</span></span></h3></main></div>]]></content:encoded>
        </item>
    </channel>
</rss>