Vue:滚动<div>到底部而不跳转

时间:2019-09-12 15:06:19

标签: scroll vuejs2

我尝试使用滚动条滚动到HTML DIV元素的底部。

很不幸,我看到窗户在跳。

这是我滚动到底部的方式:

  },
  methods: {
    scrollToEnd() {
      const container = this.$refs.messagelog
      container.scrollTop = container.scrollHeight
    }
  },
  mounted() {
    this.scrollToEnd()
  },

我试图在beforeMount上运行代码,但是DOM不在此状态下加载。

有什么主意我该如何解决跳跃的错误?

0 个答案:

没有答案