html,div,ul自动滚动到最底部

以Vue为例子,其他依次类推

 //监听数据更新
 watch: {
	data: function (data) {
	//this.$nextTick是vue内置的一个方法,具体百度
	
      this.$nextTick(() => {
        var container = this.$el.querySelector("#chat-list");//#chat-list为ul的id
        container.scrollTop = container.scrollHeight; 
     	//如果上述代码不行,依次尝试以下3个代码
		1.document.documentElement.scrollTop = container.scrollHeight;
		2.window.pageYOffset = container.scrollHeight;
		3.document.body.scrollTop = container.scrollHeight;
      });
    },
  },

你可能感兴趣的:(htm,vue,js,javascript,html)