{"id":79207,"date":"2026-03-01T13:18:12","date_gmt":"2026-03-01T05:18:12","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/79207.html"},"modified":"2026-03-01T13:18:12","modified_gmt":"2026-03-01T05:18:12","slug":"%e4%bb%8e%e5%8d%b3%e6%97%b6%e9%80%9a%e8%ae%af%e7%9a%84%e8%87%aa%e5%8a%a8%e6%bb%9a%e5%8a%a8%e9%9c%80%e6%b1%82%ef%bc%8c%e5%bd%bb%e5%ba%95%e6%90%9e%e6%87%82vue%e7%9a%84nexttick-%e5%8e%9f%e7%90%86","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/79207.html","title":{"rendered":"\u4ece\u5373\u65f6\u901a\u8baf\u7684\u81ea\u52a8\u6eda\u52a8\u9700\u6c42\uff0c\u5f7b\u5e95\u641e\u61c2Vue\u7684nextTick \u539f\u7406"},"content":{"rendered":"<p>\u4e4b\u524d\u505a\u4e00\u4e2a\u5373\u65f6\u901a\u8baf\u9879\u76ee\u65f6&#xff0c;\u9047\u5230\u4e86\u4e00\u4e2a\u5f88\u5e38\u89c1\u7684\u9700\u6c42&#xff1a;\u53d1\u9001\u6d88\u606f\u540e&#xff0c;\u7a97\u53e3\u81ea\u52a8\u6eda\u52a8\u5230\u5e95\u90e8&#xff0c;\u663e\u793a\u6700\u65b0\u6d88\u606f\u3002\u770b\u4f3c\u7b80\u5355&#xff0c;\u5374\u8ba9\u6211\u5bf9 Vue \u7684 nextTick \u6709\u4e86\u66f4\u6df1\u7684\u7406\u89e3\u3002<\/p>\n<h4>\u4e00\u3001\u9700\u6c42&#xff1a;\u6d88\u606f\u5217\u8868\u81ea\u52a8\u6eda\u52a8<\/h4>\n<p>\u5728\u5373\u65f6\u901a\u8baf&#xff08;IM&#xff09;\u5e94\u7528\u4e2d&#xff0c;\u5f53\u7528\u6237\u53d1\u9001\u6d88\u606f\u6216\u63a5\u6536\u65b0\u6d88\u606f\u65f6&#xff0c;\u6211\u4eec\u5e0c\u671b\u6d88\u606f\u5217\u8868\u80fd\u81ea\u52a8\u6eda\u52a8\u5230\u6700\u5e95\u90e8&#xff0c;\u8ba9\u7528\u6237\u7b2c\u4e00\u65f6\u95f4\u770b\u5230\u6700\u65b0\u5185\u5bb9\u3002\u901a\u5e38\u6211\u4eec\u4f1a\u8fd9\u6837\u5199&#xff1a;<\/p>\n<p><span class=\"token comment\">\/\/ \u63a5\u6536\u804a\u5929\u6d88\u606f&#xff08;\u5305\u62ec\u81ea\u5df1\u53d1\u51fa\u540e\u8fd4\u56de\u7684\u6d88\u606f&#xff09;<\/span><br \/>\nsocket<span class=\"token punctuation\">.<\/span><span class=\"token function\">on<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;receiveChatMsg&#039;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">async<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token parameter\">event<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&gt;<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  list<span class=\"token punctuation\">.<\/span>value<span class=\"token punctuation\">.<\/span><span class=\"token function\">push<\/span><span class=\"token punctuation\">(<\/span>event<span class=\"token punctuation\">)<\/span>          <span class=\"token comment\">\/\/ \u5411\u6d88\u606f\u6570\u7ec4\u6dfb\u52a0\u65b0\u6d88\u606f<\/span><br \/>\n  <span class=\"token keyword\">await<\/span> <span class=\"token function\">nextTick<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span>                 <span class=\"token comment\">\/\/ \u7b49\u5f85 DOM \u66f4\u65b0<\/span><br \/>\n  window<span class=\"token punctuation\">.<\/span><span class=\"token function\">scrollTo<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">,<\/span> document<span class=\"token punctuation\">.<\/span>body<span class=\"token punctuation\">.<\/span>scrollHeight<span class=\"token punctuation\">)<\/span>  <span class=\"token comment\">\/\/ \u6eda\u52a8\u5230\u5e95\u90e8<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>\u8fd9\u6bb5\u4ee3\u7801\u7684\u6838\u5fc3\u662f await nextTick()\u3002\u5b83\u7684\u4f5c\u7528\u662f\u7b49\u5f85 Vue \u5b8c\u6210 DOM \u66f4\u65b0&#xff0c;\u7136\u540e\u6267\u884c\u6eda\u52a8\u64cd\u4f5c\u3002\u4e3a\u4ec0\u4e48\u9700\u8981\u7b49\u5f85&#xff1f;\u5982\u679c\u4e0d\u52a0 nextTick&#xff0c;\u76f4\u63a5\u6eda\u52a8\u4f1a\u600e\u6837&#xff1f;\u8fd9\u5c31\u6d89\u53ca\u5230 Vue \u7684\u5f02\u6b65\u66f4\u65b0\u673a\u5236\u4e86\u3002<\/p>\n<h4>\u4e8c\u3001Vue \u7684\u5f02\u6b65\u66f4\u65b0\u961f\u5217\u4e0e nextTick \u7684\u5b9a\u4e49<\/h4>\n<p>Vue \u5728\u66f4\u65b0 DOM \u65f6\u662f\u5f02\u6b65\u6267\u884c\u7684\u3002\u4e5f\u5c31\u662f\u8bf4&#xff0c;\u5f53\u4f60\u4fee\u6539\u4e86\u6570\u636e&#xff08;\u6bd4\u5982 list.value.push(event)&#xff09;&#xff0c;Vue \u5e76\u4e0d\u4f1a\u7acb\u5373\u66f4\u65b0 DOM&#xff0c;\u800c\u662f\u5c06\u8fd9\u6b21\u66f4\u65b0\u63a8\u5165\u4e00\u4e2a\u961f\u5217\u4e2d&#xff0c;\u5e76\u5728\u4e0b\u4e00\u4e2a\u4e8b\u4ef6\u5faa\u73af&#xff08;tick&#xff09;\u4e2d\u6279\u91cf\u6267\u884c\u6240\u6709\u66f4\u65b0\u3002\u8fd9\u6837\u505a\u7684\u597d\u5904\u662f\u907f\u514d\u9891\u7e41\u64cd\u4f5c DOM&#xff0c;\u63d0\u5347\u6027\u80fd\u3002<\/p>\n<p>nextTick \u662f Vue \u63d0\u4f9b\u7684\u4e00\u4e2a\u65b9\u6cd5&#xff0c;\u5b83\u63a5\u6536\u4e00\u4e2a\u56de\u8c03\u51fd\u6570&#xff0c;\u5e76\u5c06\u8fd9\u4e2a\u56de\u8c03\u5ef6\u8fdf\u5230\u4e0b\u6b21 DOM \u66f4\u65b0\u5faa\u73af\u7ed3\u675f\u4e4b\u540e\u6267\u884c\u3002\u7b80\u5355\u8bf4&#xff0c;\u5c31\u662f\u7b49 DOM \u66f4\u65b0\u5b8c\u6210\u540e\u518d\u8c03\u7528\u4f60\u7684\u56de\u8c03&#xff0c;\u8fd9\u6837\u4f60\u5c31\u53ef\u4ee5\u5728\u56de\u8c03\u4e2d\u5b89\u5168\u5730\u8bbf\u95ee\u66f4\u65b0\u540e\u7684 DOM\u3002<\/p>\n<p>\u5728 Vue 3 \u4e2d&#xff0c;nextTick \u8fd4\u56de\u4e00\u4e2a Promise&#xff0c;\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u7528 await \u8bed\u6cd5&#xff0c;\u4f7f\u4ee3\u7801\u66f4\u7b80\u6d01\u3002<\/p>\n<h4>\u4e09\u3001\u4e3a\u4ec0\u4e48\u8981\u7528 nextTick&#xff1f;\u76f4\u63a5\u64cd\u4f5c DOM \u4f1a\u6709\u4ec0\u4e48\u95ee\u9898&#xff1f;<\/h4>\n<p>\u5982\u679c\u6ca1\u6709 nextTick&#xff0c;\u5728\u4fee\u6539\u6570\u636e\u540e\u7acb\u5373\u8bfb\u53d6 DOM \u7684\u6eda\u52a8\u9ad8\u5ea6&#xff0c;\u53ef\u80fd\u83b7\u53d6\u5230\u7684\u8fd8\u662f\u65e7\u503c&#xff0c;\u56e0\u4e3a DOM \u8fd8\u6ca1\u6709\u91cd\u65b0\u6e32\u67d3\u3002\u8fd9\u6837\u6eda\u52a8\u4f4d\u7f6e\u5c31\u4f1a\u51fa\u9519&#xff0c;\u53ef\u80fd\u505c\u7559\u5728\u65e7\u6d88\u606f\u7684\u5e95\u90e8&#xff0c;\u800c\u4e0d\u662f\u65b0\u6d88\u606f\u7684\u5e95\u90e8\u3002<\/p>\n<p>\u4f8b\u5982&#xff1a;<\/p>\n<p>list<span class=\"token punctuation\">.<\/span>value<span class=\"token punctuation\">.<\/span><span class=\"token function\">push<\/span><span class=\"token punctuation\">(<\/span>newMsg<span class=\"token punctuation\">)<\/span><br \/>\nwindow<span class=\"token punctuation\">.<\/span><span class=\"token function\">scrollTo<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">,<\/span> document<span class=\"token punctuation\">.<\/span>body<span class=\"token punctuation\">.<\/span>scrollHeight<span class=\"token punctuation\">)<\/span> <span class=\"token comment\">\/\/ \u53ef\u80fd scrollHeight \u8fd8\u662f\u65e7\u7684<\/span><\/p>\n<p>\u7531\u4e8e document.body.scrollHeight \u7684\u8bfb\u53d6\u53d1\u751f\u5728 DOM \u66f4\u65b0\u4e4b\u524d&#xff0c;\u6240\u4ee5\u6eda\u52a8\u4e0d\u5230\u771f\u6b63\u7684\u5e95\u90e8\u3002<\/p>\n<p>\u800c\u52a0\u4e0a nextTick \u540e&#xff0c;\u6211\u4eec\u786e\u4fdd\u4e86\u6eda\u52a8\u4ee3\u7801\u5728 DOM \u66f4\u65b0\u4e4b\u540e\u8fd0\u884c&#xff0c;\u8fd9\u65f6 scrollHeight \u5df2\u7ecf\u5305\u542b\u4e86\u65b0\u6d88\u606f\u7684\u9ad8\u5ea6&#xff0c;\u6eda\u52a8\u81ea\u7136\u5c31\u6b63\u786e\u4e86\u3002<\/p>\n<h4>\u56db\u3001nextTick \u7684\u539f\u7406&#xff1a;\u4e8b\u4ef6\u5faa\u73af\u4e0e\u5fae\u4efb\u52a1<\/h4>\n<p>nextTick \u7684\u5b9e\u73b0\u539f\u7406\u4f9d\u8d56\u4e8e JavaScript \u7684\u4e8b\u4ef6\u5faa\u73af\u673a\u5236\u3002Vue \u5185\u90e8\u4f1a\u5c1d\u8bd5\u4f7f\u7528\u539f\u751f\u7684 Promise.then\u3001MutationObserver \u6216 setImmediate&#xff08;\u5982\u679c\u73af\u5883\u652f\u6301&#xff09;&#xff0c;\u5982\u679c\u90fd\u4e0d\u652f\u6301\u5219\u964d\u7ea7\u4e3a setTimeout(fn, 0)\u3002\u5b83\u4eec\u90fd\u5c5e\u4e8e\u5fae\u4efb\u52a1\u6216\u5b8f\u4efb\u52a1&#xff0c;\u4f46 Vue \u4f18\u5148\u9009\u62e9\u5fae\u4efb\u52a1&#xff0c;\u4ee5\u786e\u4fdd\u5728\u540c\u4e00\u4e2a\u4e8b\u4ef6\u5faa\u73af\u4e2d\u5c3d\u53ef\u80fd\u65e9\u5730\u6267\u884c\u56de\u8c03\u3002<\/p>\n<p>\u7b80\u5355\u6d41\u7a0b\u5982\u4e0b&#xff1a;<\/p>\n<li>\u6570\u636e\u53d8\u66f4\u89e6\u53d1 Vue \u7684\u66f4\u65b0\u961f\u5217\u3002<\/li>\n<li>Vue \u5c06\u66f4\u65b0\u51fd\u6570\u653e\u5165\u961f\u5217&#xff0c;\u5e76\u8ba1\u5212\u5728\u4e0b\u4e00\u4e2a tick \u6267\u884c\u3002<\/li>\n<li>\u5982\u679c\u4f60\u8c03\u7528\u4e86 nextTick(callback)&#xff0c;Vue \u4f1a\u5c06\u8fd9\u4e2a callback \u653e\u5165\u4e00\u4e2a\u56de\u8c03\u961f\u5217\u4e2d&#xff0c;\u7b49\u5f85 DOM \u66f4\u65b0\u5b8c\u6210\u540e\u6267\u884c\u3002<\/li>\n<li>\u5f53\u66f4\u65b0\u961f\u5217\u6267\u884c\u5b8c\u6bd5&#xff08;DOM \u66f4\u65b0\u5b8c\u6210&#xff09;&#xff0c;nextTick \u7684\u56de\u8c03\u961f\u5217\u5f00\u59cb\u6267\u884c\u3002<\/li>\n<p>\u56e0\u6b64&#xff0c;nextTick \u80fd\u4fdd\u8bc1\u56de\u8c03\u5728 DOM \u66f4\u65b0\u540e\u89e6\u53d1\u3002<\/p>\n<h4>\u4e94\u3001nextTick \u7684\u5e38\u89c1\u5e94\u7528\u573a\u666f<\/h4>\n<p>\u9664\u4e86\u6eda\u52a8\u5b9a\u4f4d&#xff0c;nextTick \u5728\u4ee5\u4e0b\u573a\u666f\u4e5f\u7ecf\u5e38\u7528\u5230&#xff1a;<\/p>\n<li>\n<p>\u83b7\u53d6\u66f4\u65b0\u540e\u7684\u5143\u7d20\u5c3a\u5bf8\u6216\u4f4d\u7f6e \u6bd4\u5982\u52a8\u6001\u6dfb\u52a0\u5143\u7d20\u540e&#xff0c;\u9700\u8981\u83b7\u53d6\u8be5\u5143\u7d20\u7684 offsetTop \u6216 clientWidth \u6765\u8ba1\u7b97\u5e03\u5c40\u3002<\/p>\n<\/li>\n<li>\n<p>\u4e0e\u7b2c\u4e09\u65b9\u5e93\u96c6\u6210 \u6709\u4e9b\u7b2c\u4e09\u65b9\u5e93&#xff08;\u5982\u56fe\u8868\u5e93\u3001\u5bcc\u6587\u672c\u7f16\u8f91\u5668&#xff09;\u9700\u8981\u4f9d\u8d56\u771f\u5b9e\u7684 DOM \u8282\u70b9&#xff0c;\u5728\u6570\u636e\u53d8\u5316\u540e\u91cd\u65b0\u521d\u59cb\u5316\u65f6&#xff0c;\u5fc5\u987b\u5728 DOM \u66f4\u65b0\u540e\u6267\u884c\u3002<\/p>\n<\/li>\n<li>\n<p>\u89e6\u53d1\u4f9d\u8d56\u4e8e DOM \u7684\u4e8b\u4ef6 \u6bd4\u5982\u624b\u52a8\u89e6\u53d1 resize \u4e8b\u4ef6&#xff0c;\u6216\u8005\u5728\u5143\u7d20\u51fa\u73b0\u540e\u81ea\u52a8\u805a\u7126\u8f93\u5165\u6846\u3002<\/p>\n<\/li>\n<li>\n<p>\u6d4b\u8bd5\u4e2d\u7684\u65ad\u8a00 \u5728\u7f16\u5199\u5355\u5143\u6d4b\u8bd5\u65f6&#xff0c;\u6709\u65f6\u9700\u8981\u7b49\u5f85\u7ec4\u4ef6\u91cd\u65b0\u6e32\u67d3\u540e\u624d\u80fd\u5bf9 DOM \u8fdb\u884c\u65ad\u8a00\u3002<\/p>\n<\/li>\n<h4>\u516d\u3001\u6269\u5c55&#xff1a;window.scrollTo \u7684\u6df1\u5165\u7528\u6cd5<\/h4>\n<p>\u4e0a\u9762\u4ee3\u7801\u4e2d\u4f7f\u7528\u4e86 window.scrollTo(0, document.body.scrollHeight)&#xff0c;\u8fd9\u662f\u6700\u7b80\u5355\u7684\u4e00\u79cd\u8c03\u7528\u65b9\u5f0f\u3002\u5176\u5b9e scrollTo \u8fd8\u6709\u66f4\u591a\u73a9\u6cd5&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u57fa\u672c\u8bed\u6cd5 window.scrollTo(x-coord, y-coord) \u4f8b\u5982 window.scrollTo(0, 0) \u6eda\u52a8\u5230\u9875\u9762\u9876\u90e8\u3002<\/p>\n<\/li>\n<li>\n<p>\u9009\u9879\u5bf9\u8c61&#xff08;\u73b0\u4ee3\u6d4f\u89c8\u5668\u652f\u6301&#xff09;<\/p>\n<p> window<span class=\"token punctuation\">.<\/span><span class=\"token function\">scrollTo<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token literal-property property\">left<\/span><span class=\"token operator\">:<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">,<\/span><br \/>\n  <span class=\"token literal-property property\">top<\/span><span class=\"token operator\">:<\/span> document<span class=\"token punctuation\">.<\/span>body<span class=\"token punctuation\">.<\/span>scrollHeight<span class=\"token punctuation\">,<\/span><br \/>\n  <span class=\"token literal-property property\">behavior<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">&#039;smooth&#039;<\/span>   <span class=\"token comment\">\/\/ \u53ef\u9009 &#039;smooth&#039; \u5e73\u6ed1\u6eda\u52a8&#xff0c;&#039;instant&#039; \u77ac\u95f4\u6eda\u52a8&#xff0c;\u9ed8\u8ba4 &#039;auto&#039;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>\u4f7f\u7528 behavior: &#039;smooth&#039; \u53ef\u4ee5\u5b9e\u73b0\u5e73\u6ed1\u6eda\u52a8\u6548\u679c&#xff0c;\u63d0\u5347\u7528\u6237\u4f53\u9a8c\u3002<\/p>\n<\/li>\n<li>\n<p>\u517c\u5bb9\u6027\u5904\u7406 \u5982\u679c\u9700\u8981\u517c\u5bb9\u65e7\u6d4f\u89c8\u5668&#xff0c;\u53ef\u4ee5\u5148\u68c0\u6d4b\u662f\u5426\u652f\u6301\u9009\u9879\u5bf9\u8c61&#xff0c;\u5426\u5219\u56de\u9000\u5230\u57fa\u672c\u8bed\u6cd5\u3002<\/p>\n<\/li>\n<\/ul>\n<h5>\u5b9e\u73b0\u5e73\u6ed1\u6eda\u52a8\u5230\u9876\u90e8\u7684\u5c0f\u51fd\u6570<\/h5>\n<p><span class=\"token keyword\">function<\/span> <span class=\"token function\">scrollToTop<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token keyword\">const<\/span> c <span class=\"token operator\">&#061;<\/span> document<span class=\"token punctuation\">.<\/span>documentElement<span class=\"token punctuation\">.<\/span>scrollTop <span class=\"token operator\">||<\/span> document<span class=\"token punctuation\">.<\/span>body<span class=\"token punctuation\">.<\/span>scrollTop<br \/>\n  <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>c <span class=\"token operator\">&gt;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    window<span class=\"token punctuation\">.<\/span><span class=\"token function\">requestAnimationFrame<\/span><span class=\"token punctuation\">(<\/span>scrollToTop<span class=\"token punctuation\">)<\/span><br \/>\n    window<span class=\"token punctuation\">.<\/span><span class=\"token function\">scrollTo<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">,<\/span> c <span class=\"token operator\">&#8211;<\/span> c <span class=\"token operator\">\/<\/span> <span class=\"token number\">8<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\">\/\/ \u6bcf\u6b21\u51cf\u5c11\u5f53\u524d\u9ad8\u5ea6\u76841\/8&#xff0c;\u5f62\u6210\u7f13\u52a8\u6548\u679c<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token function\">scrollToTop<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>\u8fd9\u4e2a\u9012\u5f52\u51fd\u6570\u5229\u7528 requestAnimationFrame \u5b9e\u73b0\u5e73\u6ed1\u6eda\u52a8&#xff0c;\u6bcf\u6b21\u51cf\u5c11\u4e00\u5b9a\u6bd4\u4f8b&#xff0c;\u76f4\u5230\u9876\u90e8\u3002\u8fd9\u662f\u6a21\u62df\u7f13\u52a8\u7684\u7b80\u5355\u5199\u6cd5\u3002<\/p>\n<h4>\u4e03\u3001Vue 3 \u4e2d\u7684 nextTick \u4e0e Composition API<\/h4>\n<p>\u5728 Vue 3 \u7684 Composition API \u4e2d&#xff0c;nextTick \u7684\u4f7f\u7528\u66f4\u52a0\u7075\u6d3b\u3002\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u5bfc\u5165\u5e76\u4f7f\u7528&#xff1a;<\/p>\n<p><span class=\"token keyword\">import<\/span> <span class=\"token punctuation\">{<\/span> nextTick <span class=\"token punctuation\">}<\/span> <span class=\"token keyword\">from<\/span> <span class=\"token string\">&#039;vue&#039;<\/span><\/p>\n<p><span class=\"token keyword\">async<\/span> <span class=\"token keyword\">function<\/span> <span class=\"token function\">addMessage<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  messages<span class=\"token punctuation\">.<\/span>value<span class=\"token punctuation\">.<\/span><span class=\"token function\">push<\/span><span class=\"token punctuation\">(<\/span>newMsg<span class=\"token punctuation\">)<\/span><br \/>\n  <span class=\"token keyword\">await<\/span> <span class=\"token function\">nextTick<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n  <span class=\"token comment\">\/\/ \u6b64\u65f6 DOM \u5df2\u66f4\u65b0<\/span><br \/>\n  <span class=\"token function\">scrollToBottom<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u5f53\u7136&#xff0c;\u4e5f\u53ef\u4ee5\u4f20\u5165\u56de\u8c03\u51fd\u6570\u5f62\u5f0f&#xff1a;<\/p>\n<p><span class=\"token function\">nextTick<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&gt;<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token function\">scrollToBottom<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>\u6269\u5c55\u9605\u8bfb<\/p>\n<ul>\n<li>Vue.js \u5b98\u65b9\u6587\u6863&#xff1a;\u5f02\u6b65\u66f4\u65b0\u961f\u5217<\/li>\n<li>JavaScript \u4e8b\u4ef6\u5faa\u73af\u673a\u5236\u8be6\u89e3<\/li>\n<li>window.scrollTo MDN \u6587\u6863<\/li>\n<\/ul>\n<p>\u5982\u679c\u4f60\u89c9\u5f97\u8fd9\u7bc7\u6587\u7ae0\u5bf9\u4f60\u6709\u5e2e\u52a9&#xff0c;\u6b22\u8fce\u70b9\u8d5e\u6536\u85cf&#xff0c;\u4e5f\u6b22\u8fce\u5728\u8bc4\u8bba\u533a\u5206\u4eab\u4f60\u5728\u9879\u76ee\u4e2d\u9047\u5230\u7684 DOM \u66f4\u65b0\u95ee\u9898&#xff01;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e4b\u524d\u505a\u4e00\u4e2a\u5373\u65f6\u901a\u8baf\u9879\u76ee\u65f6&#xff0c;\u9047\u5230\u4e86\u4e00\u4e2a\u5f88\u5e38\u89c1\u7684\u9700\u6c42&#xff1a;\u53d1\u9001\u6d88\u606f\u540e&#xff0c;\u7a97\u53e3\u81ea\u52a8\u6eda\u52a8\u5230\u5e95\u90e8&#xff0c;\u663e\u793a\u6700\u65b0\u6d88\u606f\u3002\u770b\u4f3c\u7b80\u5355&#xff0c;\u5374\u8ba9\u6211\u5bf9 Vue \u7684 nextTick \u6709\u4e86\u66f4\u6df1\u7684\u7406\u89e3\u3002<br \/>\n\u4e00\u3001\u9700\u6c42&#xff1a;\u6d88\u606f\u5217\u8868\u81ea\u52a8\u6eda\u52a8<br \/>\n\u5728\u5373\u65f6\u901a\u8baf&#xff08;IM&#xff09;\u5e94\u7528\u4e2d&#xff0c;\u5f53\u7528\u6237\u53d1\u9001\u6d88\u606f\u6216\u63a5\u6536\u65b0\u6d88\u606f\u65f6&#xff0c;\u6211\u4eec\u5e0c\u671b\u6d88\u606f\u5217\u8868\u80fd\u81ea\u52a8\u6eda\u52a8\u5230\u6700\u5e95\u90e8&#xff0c;\u8ba9\u7528\u6237\u7b2c\u4e00\u65f6\u95f4\u770b\u5230\u6700\u65b0\u5185\u5bb9\u3002\u901a\u5e38\u6211\u4eec\u4f1a<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[187,625,87],"topic":[],"class_list":["post-79207","post","type-post","status-publish","format-standard","hentry","category-server","tag-javascript","tag-vue-js","tag-87"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4ece\u5373\u65f6\u901a\u8baf\u7684\u81ea\u52a8\u6eda\u52a8\u9700\u6c42\uff0c\u5f7b\u5e95\u641e\u61c2Vue\u7684nextTick \u539f\u7406 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/79207.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4ece\u5373\u65f6\u901a\u8baf\u7684\u81ea\u52a8\u6eda\u52a8\u9700\u6c42\uff0c\u5f7b\u5e95\u641e\u61c2Vue\u7684nextTick \u539f\u7406 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4e4b\u524d\u505a\u4e00\u4e2a\u5373\u65f6\u901a\u8baf\u9879\u76ee\u65f6&#xff0c;\u9047\u5230\u4e86\u4e00\u4e2a\u5f88\u5e38\u89c1\u7684\u9700\u6c42&#xff1a;\u53d1\u9001\u6d88\u606f\u540e&#xff0c;\u7a97\u53e3\u81ea\u52a8\u6eda\u52a8\u5230\u5e95\u90e8&#xff0c;\u663e\u793a\u6700\u65b0\u6d88\u606f\u3002\u770b\u4f3c\u7b80\u5355&#xff0c;\u5374\u8ba9\u6211\u5bf9 Vue \u7684 nextTick \u6709\u4e86\u66f4\u6df1\u7684\u7406\u89e3\u3002 \u4e00\u3001\u9700\u6c42&#xff1a;\u6d88\u606f\u5217\u8868\u81ea\u52a8\u6eda\u52a8 \u5728\u5373\u65f6\u901a\u8baf&#xff08;IM&#xff09;\u5e94\u7528\u4e2d&#xff0c;\u5f53\u7528\u6237\u53d1\u9001\u6d88\u606f\u6216\u63a5\u6536\u65b0\u6d88\u606f\u65f6&#xff0c;\u6211\u4eec\u5e0c\u671b\u6d88\u606f\u5217\u8868\u80fd\u81ea\u52a8\u6eda\u52a8\u5230\u6700\u5e95\u90e8&#xff0c;\u8ba9\u7528\u6237\u7b2c\u4e00\u65f6\u95f4\u770b\u5230\u6700\u65b0\u5185\u5bb9\u3002\u901a\u5e38\u6211\u4eec\u4f1a\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/79207.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-03-01T05:18:12+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/79207.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/79207.html\",\"name\":\"\u4ece\u5373\u65f6\u901a\u8baf\u7684\u81ea\u52a8\u6eda\u52a8\u9700\u6c42\uff0c\u5f7b\u5e95\u641e\u61c2Vue\u7684nextTick \u539f\u7406 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-03-01T05:18:12+00:00\",\"dateModified\":\"2026-03-01T05:18:12+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/79207.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/79207.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/79207.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4ece\u5373\u65f6\u901a\u8baf\u7684\u81ea\u52a8\u6eda\u52a8\u9700\u6c42\uff0c\u5f7b\u5e95\u641e\u61c2Vue\u7684nextTick \u539f\u7406\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u4ece\u5373\u65f6\u901a\u8baf\u7684\u81ea\u52a8\u6eda\u52a8\u9700\u6c42\uff0c\u5f7b\u5e95\u641e\u61c2Vue\u7684nextTick \u539f\u7406 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/79207.html","og_locale":"zh_CN","og_type":"article","og_title":"\u4ece\u5373\u65f6\u901a\u8baf\u7684\u81ea\u52a8\u6eda\u52a8\u9700\u6c42\uff0c\u5f7b\u5e95\u641e\u61c2Vue\u7684nextTick \u539f\u7406 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4e4b\u524d\u505a\u4e00\u4e2a\u5373\u65f6\u901a\u8baf\u9879\u76ee\u65f6&#xff0c;\u9047\u5230\u4e86\u4e00\u4e2a\u5f88\u5e38\u89c1\u7684\u9700\u6c42&#xff1a;\u53d1\u9001\u6d88\u606f\u540e&#xff0c;\u7a97\u53e3\u81ea\u52a8\u6eda\u52a8\u5230\u5e95\u90e8&#xff0c;\u663e\u793a\u6700\u65b0\u6d88\u606f\u3002\u770b\u4f3c\u7b80\u5355&#xff0c;\u5374\u8ba9\u6211\u5bf9 Vue \u7684 nextTick \u6709\u4e86\u66f4\u6df1\u7684\u7406\u89e3\u3002 \u4e00\u3001\u9700\u6c42&#xff1a;\u6d88\u606f\u5217\u8868\u81ea\u52a8\u6eda\u52a8 \u5728\u5373\u65f6\u901a\u8baf&#xff08;IM&#xff09;\u5e94\u7528\u4e2d&#xff0c;\u5f53\u7528\u6237\u53d1\u9001\u6d88\u606f\u6216\u63a5\u6536\u65b0\u6d88\u606f\u65f6&#xff0c;\u6211\u4eec\u5e0c\u671b\u6d88\u606f\u5217\u8868\u80fd\u81ea\u52a8\u6eda\u52a8\u5230\u6700\u5e95\u90e8&#xff0c;\u8ba9\u7528\u6237\u7b2c\u4e00\u65f6\u95f4\u770b\u5230\u6700\u65b0\u5185\u5bb9\u3002\u901a\u5e38\u6211\u4eec\u4f1a","og_url":"https:\/\/www.wsisp.com\/helps\/79207.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-03-01T05:18:12+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/79207.html","url":"https:\/\/www.wsisp.com\/helps\/79207.html","name":"\u4ece\u5373\u65f6\u901a\u8baf\u7684\u81ea\u52a8\u6eda\u52a8\u9700\u6c42\uff0c\u5f7b\u5e95\u641e\u61c2Vue\u7684nextTick \u539f\u7406 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-03-01T05:18:12+00:00","dateModified":"2026-03-01T05:18:12+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/79207.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/79207.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/79207.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u4ece\u5373\u65f6\u901a\u8baf\u7684\u81ea\u52a8\u6eda\u52a8\u9700\u6c42\uff0c\u5f7b\u5e95\u641e\u61c2Vue\u7684nextTick \u539f\u7406"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/79207","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=79207"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/79207\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=79207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=79207"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=79207"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=79207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}