vue中的nextTick

在 Vue.js 中, nextTick方法用于在 DOM 更新之后执行回调函数。它的使用方式是调用 this.$nextTick(),并传入一个回调函数作为参数。回调函数将在 DOM 更新之后被执行,这样可以确保在修改数据之后立即操作 DOM。

00); }, Math.max(100, 16) * (index + 1)); }); }); var chatQuotes = document.querySelectorAll(".chat .talk .quote"); chatQuotes.forEach((quote) => { quote.addEventListener('click', function () { var chatCellDom = document.getElementById("quote-" + quote.getAttribute("quotedCellTag")); if (chatCellDom) { var chatDiv = chatCellDom.parentElement; var mid = chatDiv.clientHeight / 2; var offsetTop = chatCellDom.offsetTop; if (offsetTop > mid - chatCellDom.clientHeight / 2) { chatDiv.scrollTo({ top: chatCellDom.offsetTop - mid + chatCellDom.clientHeight / 2, behavior: "smooth" }); } else { chatDiv.scrollTo({ top: 0, behavior: "smooth" }); } chat_quote_obverser.observe(chatCellDom); } }); }); });