{"id":403,"date":"2021-01-19T09:47:04","date_gmt":"2021-01-19T01:47:04","guid":{"rendered":"http:\/\/zhuxinyong.com\/?p=403"},"modified":"2021-01-19T09:52:04","modified_gmt":"2021-01-19T01:52:04","slug":"%e4%bb%8e-vue3-%e6%ba%90%e7%a0%81%e4%b8%ad%e5%86%8d%e8%b0%88-nexttick","status":"publish","type":"post","link":"https:\/\/zhuxinyong.com\/?p=403","title":{"rendered":"\u4ece Vue3 \u6e90\u7801\u4e2d\u518d\u8c08 nextTick"},"content":{"rendered":"\n<p>\u5f00\u59cb\u4e4b\u524d\u5148\u770b\u4e0b\u5b98\u65b9\u5bf9\u5176\u7684\u5b9a\u4e49<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u5b9a\u4e49: \u5728\u4e0b\u6b21 DOM \u66f4\u65b0\u5faa\u73af\u7ed3\u675f\u4e4b\u540e\u6267\u884c\u5ef6\u8fdf\u56de\u8c03\u3002\u5728\u4fee\u6539\u6570\u636e\u4e4b\u540e\u7acb\u5373\u4f7f\u7528\u8fd9\u4e2a\u65b9\u6cd5\uff0c\u83b7\u53d6\u66f4\u65b0\u540e\u7684 DOM<\/p><\/blockquote>\n\n\n\n<p>\u770b\u5b8c\u662f\u4e0d\u662f\u6709\u4e00\u5806\u95ee\u53f7\uff1f\u6211\u4eec\u4ece\u4e2d\u627e\u51fa\u6765\u4ea7\u751f\u95ee\u53f7\u7684\u5173\u952e\u8bcd<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u4e0b\u6b21 DOM \u66f4\u65b0\u5faa\u73af\u7ed3\u675f\u4e4b\u540e?<\/li><li>\u6267\u884c\u5ef6\u8fdf\u56de\u8c03?<\/li><li>\u66f4\u65b0\u540e\u7684 DOM?<\/li><\/ul>\n\n\n\n<p>\u4ece\u4e0a\u9762\u4e09\u4e2a\u7591\u95ee\u5927\u80c6\u731c\u60f3\u4e00\u4e0b<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>vue \u66f4\u65b0DOM\u662f\u6709\u7b56\u7565\u7684\uff0c\u4e0d\u662f\u540c\u6b65\u66f4\u65b0<\/li><li>nextTick \u53ef\u4ee5\u63a5\u6536\u4e00\u4e2a\u51fd\u6570\u505a\u4e3a\u5165\u53c2<\/li><li>nextTick \u540e\u80fd\u62ff\u5230\u6700\u65b0\u7684\u6570\u636e<\/li><\/ul>\n\n\n\n<p>\u597d\u4e86\uff0c\u95ee\u9898\u90fd\u629b\u51fa\u6765\u4e86\uff0c\u5148\u6765\u770b\u4e00\u4e0b\u5982\u4f55\u4f7f\u7528<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import { createApp, nextTick } from 'vue'\nconst app = createApp({\n  setup() {\n    const message = ref('Hello!')\n    const changeMessage = async newMessage => {\n      message.value = newMessage\n      \/\/ \u8fd9\u91cc\u83b7\u53d6DOM\u7684value\u662f\u65e7\u503c\n      await nextTick()\n      \/\/ nextTick \u540e\u83b7\u53d6DOM\u7684value\u662f\u66f4\u65b0\u540e\u7684\u503c\n      console.log('Now DOM is updated')\n    }\n  }\n})<\/pre>\n\n\n\n<p>&lt;a href=&#8221;https:\/\/vue3js.cn\/run\/nextTick&#8221; target=&#8221;_blank&#8221;&gt;\u4eb2\u81ea\u8bd5\u4e00\u8bd5&lt;\/a&gt;<\/p>\n\n\n\n<p>\u90a3\u4e48&nbsp;<code>nextTick<\/code>&nbsp;\u662f\u600e\u4e48\u505a\u5230\u7684\u5462\uff1f\u4e3a\u4e86\u540e\u9762\u7684\u5185\u5bb9\u66f4\u597d\u7406\u89e3\uff0c\u8fd9\u91cc\u6211\u4eec\u5f97\u4ece&nbsp;<code>js<\/code>&nbsp;\u7684\u6267\u884c\u673a\u5236\u8bf4\u8d77<\/p>\n\n\n\n<p><strong>JS\u6267\u884c\u673a\u5236<\/strong><\/p>\n\n\n\n<p>\u6211\u4eec\u90fd\u77e5\u9053&nbsp;<code>JS<\/code>&nbsp;\u662f\u5355\u7ebf\u7a0b\u8bed\u8a00\uff0c\u5373\u6307\u67d0\u4e00\u65f6\u95f4\u5185\u53ea\u80fd\u5e72\u4e00\u4ef6\u4e8b\uff0c\u6709\u7684\u540c\u5b66\u53ef\u80fd\u4f1a\u95ee\uff0c\u4e3a\u4ec0\u4e48&nbsp;<code>JS<\/code>&nbsp;\u4e0d\u80fd\u662f\u591a\u7ebf\u7a0b\u5462\uff1f\u591a\u7ebf\u7a0b\u5c31\u80fd\u540c\u4e00\u65f6\u95f4\u5185\u5e72\u591a\u4ef6\u4e8b\u60c5\u4e86<\/p>\n\n\n\n<p>\u662f\u5426\u591a\u7ebf\u7a0b\u8fd9\u4e2a\u53d6\u51b3\u4e8e\u8bed\u8a00\u7684\u7528\u9014\uff0c\u4e00\u4e2a\u5f88\u7b80\u5355\u7684\u4f8b\u5b50\uff0c\u5982\u679c\b\u540c\u4e00\u65f6\u95f4\uff0c\u4e00\u4e2a\u6dfb\u52a0\u4e86&nbsp;<code>DOM<\/code>\uff0c\u4e00\u4e2a\u5220\u9664\u4e86&nbsp;<code>DOM<\/code>, \u8fd9\u4e2a\u65f6\u5019\u8bed\u8a00\u5c31\u4e0d\u77e5\u9053\u662f\u8be5\u6dfb\u8fd8\u662f\u8be5\u5220\u4e86\uff0c\u6240\u4ee5\u4ece\u5e94\u7528\u573a\u666f\u6765\u770b&nbsp;<code>JS<\/code>&nbsp;\u53ea\u80fd\u662f\u5355\u7ebf\u7a0b<\/p>\n\n\n\n<p>\u5355\u7ebf\u7a0b\u5c31\u610f\u5473\u7740\u6211\u4eec\u6240\u6709\u7684\u4efb\u52a1\u90fd\u9700\u8981\u6392\u961f\uff0c\u540e\u9762\u7684\u4efb\u52a1\u5fc5\u987b\u7b49\u5f85\u524d\u9762\u7684\u4efb\u52a1\u5b8c\u6210\u624d\u80fd\u6267\u884c\uff0c\u5982\u679c\u524d\u9762\u7684\u4efb\u52a1\u8017\u65f6\u5f88\u957f\uff0c\u4e00\u4e9b\u4ece\u7528\u6237\u89d2\u5ea6\u4e0a\u4e0d\u9700\u8981\u7b49\u5f85\u7684\u4efb\u52a1\u5c31\u4f1a\u4e00\u76f4\u7b49\u5f85\uff0c\u8fd9\u4e2a\u4ece\u4f53\u9a8c\u89d2\u5ea6\u4e0a\u6765\u8bb2\u662f\u4e0d\u53ef\u63a5\u53d7\u7684\uff0c\u6240\u4ee5<code>JS<\/code>\u4e2d\u5c31\u51fa\u73b0\u4e86\u5f02\u6b65\u7684\u6982\u5ff5<\/p>\n\n\n\n<p><strong>\u6982\u5ff5<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u540c\u6b65 \u5728\u4e3b\u7ebf\u7a0b\u4e0a\u6392\u961f\u6267\u884c\u7684\u4efb\u52a1\uff0c\u53ea\u6709\u524d\u4e00\u4e2a\u4efb\u52a1\u6267\u884c\u5b8c\u6bd5\uff0c\u624d\u80fd\u6267\u884c\u540e\u4e00\u4e2a\u4efb\u52a1<\/li><li>\u5f02\u6b65 \u4e0d\u8fdb\u5165\u4e3b\u7ebf\u7a0b\u3001\u800c\u8fdb\u5165&#8221;\u4efb\u52a1\u961f\u5217&#8221;\uff08task queue\uff09\u7684\u4efb\u52a1\uff0c\u53ea\u6709&#8221;\u4efb\u52a1\u961f\u5217&#8221;\u901a\u77e5\u4e3b\u7ebf\u7a0b\uff0c\u67d0\u4e2a\u5f02\u6b65\u4efb\u52a1\u53ef\u4ee5\u6267\u884c\u4e86\uff0c\u8be5\u4efb\u52a1\u624d\u4f1a\u8fdb\u5165\u4e3b\u7ebf\u7a0b\u6267\u884c<\/li><\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">\u8fd0\u884c\u673a\u5236<\/h4>\n\n\n\n<ul class=\"wp-block-list\"><li>\uff081\uff09\u6240\u6709\u540c\u6b65\u4efb\u52a1\u90fd\u5728\u4e3b\u7ebf\u7a0b\u4e0a\u6267\u884c\uff0c\u5f62\u6210\u4e00\u4e2a\u6267\u884c\u6808\uff08execution context stack\uff09\u3002<\/li><li>\uff082\uff09\u4e3b\u7ebf\u7a0b\u4e4b\u5916\uff0c\u8fd8\u5b58\u5728\u4e00\u4e2a&#8221;\u4efb\u52a1\u961f\u5217&#8221;\uff08task queue\uff09\u3002\u53ea\u8981\u5f02\u6b65\u4efb\u52a1\u6709\u4e86\u8fd0\u884c\u7ed3\u679c\uff0c\u5c31\u5728&#8221;\u4efb\u52a1\u961f\u5217&#8221;\u4e4b\u4e2d\u653e\u7f6e\u4e00\u4e2a\u4e8b\u4ef6\u3002<\/li><li>\uff083\uff09\u4e00\u65e6&#8221;\u6267\u884c\u6808&#8221;\u4e2d\u7684\u6240\u6709\u540c\u6b65\u4efb\u52a1\u6267\u884c\u5b8c\u6bd5\uff0c\u7cfb\u7edf\u5c31\u4f1a\u8bfb\u53d6&#8221;\u4efb\u52a1\u961f\u5217&#8221;\uff0c\u770b\u770b\u91cc\u9762\u6709\u54ea\u4e9b\u4e8b\u4ef6\u3002\u90a3\u4e9b\u5bf9\u5e94\u7684\u5f02\u6b65\u4efb\u52a1\uff0c\u4e8e\u662f\u7ed3\u675f\u7b49\u5f85\u72b6\u6001\uff0c\u8fdb\u5165\u6267\u884c\u6808\uff0c\u5f00\u59cb\u6267\u884c\u3002<\/li><li>\uff084\uff09\u4e3b\u7ebf\u7a0b\u4e0d\u65ad\u91cd\u590d\u4e0a\u9762\u7684\u7b2c\u4e09\u6b65<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"732\" src=\"http:\/\/zhuxinyong.com\/wp-content\/uploads\/2021\/01\/555-1024x732.png\" alt=\"\" class=\"wp-image-404\" srcset=\"https:\/\/zhuxinyong.com\/wp-content\/uploads\/2021\/01\/555-1024x732.png 1024w, https:\/\/zhuxinyong.com\/wp-content\/uploads\/2021\/01\/555-300x214.png 300w, https:\/\/zhuxinyong.com\/wp-content\/uploads\/2021\/01\/555-280x200.png 280w, https:\/\/zhuxinyong.com\/wp-content\/uploads\/2021\/01\/555-768x549.png 768w, https:\/\/zhuxinyong.com\/wp-content\/uploads\/2021\/01\/555.png 1114w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><strong>nextTick<\/strong><\/p>\n\n\n\n<p>\u73b0\u5728\u6211\u4eec\u56de\u6765<code>vue<\/code>\u4e2d\u7684<code>nextTick<\/code><\/p>\n\n\n\n<p>\u5b9e\u73b0\u5f88\u7b80\u5355\uff0c\u5b8c\u5168\u662f\u57fa\u4e8e\u8bed\u8a00\u6267\u884c\u673a\u5236\u5b9e\u73b0\uff0c\u76f4\u63a5\u521b\u5efa\u4e00\u4e2a\u5f02\u6b65\u4efb\u52a1\uff0c\u90a3\u4e48<code>nextTick<\/code>\u81ea\u7136\u5c31\u8fbe\u5230\u5728\u540c\u6b65\u4efb\u52a1\u540e\u6267\u884c\u7684\u76ee\u7684<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">const p = Promise.resolve()\nexport function nextTick(fn?: () => void): Promise&lt;void> {\n  return fn ? p.then(fn) : p\n}<\/pre>\n\n\n\n<p>&lt;a href=&#8221;https:\/\/vue3js.cn\/run\/nextTick-demo-1.html&#8221; target=&#8221;_blank&#8221;&gt;\u4eb2\u81ea\u8bd5\u4e00\u8bd5&lt;\/a&gt;<\/p>\n\n\n\n<p>\u770b\u5230\u8fd9\u91cc\uff0c\u6709\u7684\u540c\u5b66\u53ef\u80fd\u53c8\u4f1a\u95ee\uff0c\u524d\u9762\u6211\u4eec\u731c\u60f3\u7684&nbsp;<code>DOM<\/code>&nbsp;\u66f4\u65b0\u4e5f\u662f\u5f02\u6b65\u4efb\u52a1\uff0c\u90a3\u4ed6\u4eec\u7684\u8fd9\u4e2a\u6267\u884c\u987a\u5e8f\u5982\u4f55\u4fdd\u8bc1\u5462\uff1f<\/p>\n\n\n\n<p>\u522b\u6025\uff0c\u5728\u6e90\u7801\u4e2d<code>nextTick<\/code>\u8fd8\u6709\u51e0\u4e2a\u5144\u5f1f\u51fd\u6570\uff0c\u6211\u4eec\u63a5\u7740\u5f80\u4e0b\u770b<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">queueJob and queuePostFlushCb<\/h4>\n\n\n\n<p><code>queueJob<\/code>&nbsp;\u7ef4\u62a4job\u5217\u961f\uff0c\u6709\u53bb\u91cd\u903b\u8f91\uff0c\u4fdd\u8bc1\u4efb\u52a1\u7684\u552f\u4e00\u6027\uff0c\u6bcf\u6b21\u8c03\u7528\u53bb\u6267\u884c&nbsp;<code>queueFlush<\/code>&nbsp;<code>queuePostFlushCb<\/code>&nbsp;\u7ef4\u62a4cb\u5217\u961f\uff0c\u88ab\u8c03\u7528\u7684\u65f6\u5019\u53bb\u91cd\uff0c\u6bcf\u6b21\u8c03\u7528\u53bb\u6267\u884c&nbsp;<code>queueFlush<\/code><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">const queue: (Job | null)[] = []\nexport function queueJob(job: Job) {\n  \/\/ \u53bb\u91cd \n  if (!queue.includes(job)) {\n    queue.push(job)\n    queueFlush()\n  }\n}\n\nexport function queuePostFlushCb(cb: Function | Function[]) {\n  if (!isArray(cb)) {\n    postFlushCbs.push(cb)\n  } else {\n    postFlushCbs.push(...cb)\n  }\n  queueFlush()\n}<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">queueFlush<\/h4>\n\n\n\n<p>\u5f00\u542f\u5f02\u6b65\u4efb\u52a1(nextTick)\u5904\u7406&nbsp;<code>flushJobs<\/code><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">function queueFlush() {\n  \/\/ \u907f\u514d\u91cd\u590d\u8c03\u7528flushJobs\n  if (!isFlushing &amp;&amp; !isFlushPending) {\n    isFlushPending = true\n    nextTick(flushJobs)\n  }\n}<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">flushJobs<\/h4>\n\n\n\n<p>\u5904\u7406\u5217\u961f\b\uff0c\u5148\u5bf9\u5217\u961f\u8fdb\u884c\u6392\u5e8f\uff0c\u6267\u884c<code>queue<\/code>\u4e2d\u7684<code>job<\/code>\uff0c\u5904\u7406\u5b8c\u540e\u518d\u5904\u7406<code>postFlushCbs<\/code>, \u5982\u679c\u961f\u5217\u6ca1\u6709\u88ab\u6e05\u7a7a\u4f1a\u9012\u5f52\u8c03\u7528<code>flushJobs<\/code>\u6e05\u7a7a\u961f\u5217<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">function flushJobs(seen?: CountMap) {\n  isFlushPending = false\n  isFlushing = true\n  let job\n  if (__DEV__) {\n    seen = seen || new Map()\n  }\n\n  \/\/ Sort queue before flush.\n  \/\/ This ensures that:\n  \/\/ 1. Components are updated from parent to child. (because parent is always\n  \/\/    created before the child so its render effect will have smaller\n  \/\/    priority number)\n  \/\/ 2. If a component is unmounted during a parent component's update,\n  \/\/    its update can be skipped.\n  \/\/ Jobs can never be null before flush starts, since they are only invalidated\n  \/\/ during execution of another flushed job.\n  queue.sort((a, b) => getId(a!) - getId(b!))\n\n  while ((job = queue.shift()) !== undefined) {\n    if (job === null) {\n      continue\n    }\n    if (__DEV__) {\n      checkRecursiveUpdates(seen!, job)\n    }\n    callWithErrorHandling(job, null, ErrorCodes.SCHEDULER)\n  }\n  flushPostFlushCbs(seen)\n  isFlushing = false\n  \/\/ some postFlushCb queued jobs!\n  \/\/ keep flushing until it drains.\n  if (queue.length || postFlushCbs.length) {\n    flushJobs(seen)\n  }\n}<\/pre>\n\n\n\n<p>\u597d\u4e86\uff0c\u5b9e\u73b0\u5168\u5728\u4e0a\u9762\u4e86\uff0c\u597d\u50cf\u8fd8\u6ca1\u6709\u89e3\u5f00\u6211\u4eec\u7684\u7591\u95ee\uff0c\u6211\u4eec\u9700\u8981\u641e\u6e05\u695a&nbsp;<code>queueJob<\/code>&nbsp;\u53ca&nbsp;<code>queuePostFlushCb<\/code>&nbsp;\u662f\u600e\u4e48\u88ab\u8c03\u7528\u7684<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/  renderer.ts\nfunction createDevEffectOptions(\n  instance: ComponentInternalInstance\n): ReactiveEffectOptions {\n  return {\n    scheduler: queueJob,\n    onTrack: instance.rtc ? e => invokeArrayFns(instance.rtc!, e) : void 0,\n    onTrigger: instance.rtg ? e => invokeArrayFns(instance.rtg!, e) : void 0\n  }\n}\n\n\/\/ effect.ts\nconst run = (effect: ReactiveEffect) => {\n  ...\n\n  if (effect.options.scheduler) {\n    effect.options.scheduler(effect)\n  } else {\n    effect()\n  }\n}<\/pre>\n\n\n\n<p>\u770b\u5230\u8fd9\u91cc\u6709\u6ca1\u6709\u604d\u7136\u5927\u609f\u7684\u611f\u89c9\uff1f\u539f\u6765\u5f53\u54cd\u5e94\u5f0f\u5bf9\u8c61\u53d1\u751f\u6539\u53d8\u540e\uff0c\u6267\u884c&nbsp;<code>effect<\/code>&nbsp;\u5982\u679c\u6709&nbsp;<code>scheduler<\/code>&nbsp;\u8fd9\u4e2a\u53c2\u6570\uff0c\u4f1a\u6267\u884c\u8fd9\u4e2a&nbsp;<code>scheduler<\/code>&nbsp;\u51fd\u6570\uff0c\u5e76\u4e14\u628a&nbsp;<code>effect<\/code>&nbsp;\u5f53\u505a\u53c2\u6570\u4f20\u5165<\/p>\n\n\n\n<p>\u7ed5\u53e3\u4e86\uff0c\u7b80\u5355\u70b9\u5c31\u662f&nbsp;<code>queueJob(effect)<\/code>\uff0c\u55ef\uff0c\u6e05\u695a\u4e86\uff0c\u8fd9\u4e5f\u662f\u6570\u636e\u53d1\u751f\u6539\u53d8\u540e\u9875\u9762\u4e0d\u4f1a\u7acb\u5373\u66f4\u65b0\u7684\u539f\u56e0<\/p>\n\n\n\n<p><a href=\"https:\/\/vue3js.cn\/reactivity\/effect.html\" target=\"_blank\" rel=\"noopener\">effect\u4f20\u9001\u95e8<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u4e3a\u4ec0\u4e48\u8981\u7528nextTick<\/h3>\n\n\n\n<p>\u4e00\u4e2a\u4f8b\u5b50\u8ba9\u5927\u5bb6\u660e\u767d<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">{{num}}\nfor(let i=0; i&lt;100000; i++){\n\tnum = i\n}<\/pre>\n\n\n\n<p>\u5982\u679c\u6ca1\u6709&nbsp;<code>nextTick<\/code>&nbsp;\u66f4\u65b0\u673a\u5236\uff0c\u90a3\u4e48&nbsp;<code>num<\/code>&nbsp;\u6bcf\u6b21\u66f4\u65b0\u503c\u90fd\u4f1a\u89e6\u53d1\u89c6\u56fe\u66f4\u65b0\uff0c\u6709\u4e86<code>nextTick<\/code>\u673a\u5236\uff0c\u53ea\u9700\u8981\u66f4\u65b0\u4e00\u6b21\uff0c\u6240\u4ee5\u4e3a\u4ec0\u4e48\u6709<code>nextTick<\/code>\u5b58\u5728\uff0c\u76f8\u4fe1\u5927\u5bb6\u5fc3\u91cc\u5df2\u7ecf\u6709\u7b54\u6848\u4e86\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u603b\u7ed3<\/h3>\n\n\n\n<p><code>nextTick<\/code>\u00a0\u662f\u00a0<code>vue<\/code>\u00a0\u4e2d\u7684\b\u66f4\u65b0\u7b56\u7565\uff0c\u4e5f\u662f\u6027\u80fd\u4f18\u5316\u624b\u6bb5\uff0c\u57fa\u4e8e<code>JS<\/code>\u6267\u884c\u673a\u5236\u5b9e\u73b0<\/p>\n\n\n\n<p><code>vue<\/code>\u00a0\u4e2d\u6211\u4eec\u6539\u53d8\u6570\u636e\u65f6\u4e0d\u4f1a\u7acb\u5373\u89e6\u53d1\u89c6\u56fe\uff0c\u5982\u679c\u9700\u8981\u5b9e\u65f6\u83b7\u53d6\u5230\u6700\u65b0\u7684<code>DOM<\/code>\uff0c\u8fd9\u4e2a\u65f6\u5019\u53ef\u4ee5\u624b\u52a8\u8c03\u7528\u00a0<code>nextTick<\/code><\/p>\n\n\n\n<pre id=\"block-f5febef1-9ced-4db3-b8d8-b5aefad3dd3e\" class=\"wp-block-preformatted\">\u539f\u6587\uff1ahttps:\/\/my.oschina.net\/u\/4586970\/blog\/4739899<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5f00\u59cb\u4e4b\u524d\u5148\u770b\u4e0b\u5b98\u65b9\u5bf9\u5176\u7684\u5b9a\u4e49 \u5b9a\u4e49: \u5728\u4e0b\u6b21 DOM \u66f4\u65b0\u5faa\u73af\u7ed3\u675f\u4e4b\u540e\u6267\u884c\u5ef6\u8fdf\u56de\u8c03\u3002\u5728\u4fee\u6539\u6570\u636e\u4e4b\u540e\u7acb&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":404,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,20,3],"tags":[6,22],"class_list":["post-403","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-all","category-frontend","category-tech","tag-javascript","tag-vuejs"],"_links":{"self":[{"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/posts\/403","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=403"}],"version-history":[{"count":5,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/posts\/403\/revisions"}],"predecessor-version":[{"id":409,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/posts\/403\/revisions\/409"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/media\/404"}],"wp:attachment":[{"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=403"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=403"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=403"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}