首先在最外层 绑定id
下面是调用的方法
回到顶部 goBackTop() { this.$nextTick(() => { const dialogEl = document.getElementById('dialogId');//获取id if (dialogEl) { const scrollContainer = dialogEl.querySelector('.el-dialog__body'); if (scrollContainer) { scrollContainer.scrollTo({ top: 0, behavior: 'smooth' }); } } }); },//回到底部 goToBottom() { this.$nextTick(function () { const dialogEl = document.getElementById('dialogId'); if (dialogEl) { const dialogHeight = dialogEl.offsetHeight const scrollContainer = dialogEl.querySelector('.el-dialog__body'); if (scrollContainer) { scrollContainer.scrollTo({ top: dialogHeight, behavior: 'smooth' }); } } }); },