示例:
var element = document.getElementById("box");
element.scrollIntoView();
element.scrollIntoView(false);
element.scrollIntoView({block: "end"});
element.scrollIntoView({behavior: "smooth", block: "end", inline: "nearest"});
在vue中使用,注意方法再mounted中调用
this.$nextTick(()=>{
//水平滑动到指定元素
document.querySelector("#box").scrollIntoView()
})