document.write("");

vue 根据div id 滚动到指定view到可视视图中

<div id="name" @click="scrollToViewById('name')"> ...... </div>

  

scrollToViewById(id) {
	if (id == '') {
		return
	}
	this.$nextTick(() => {
		document.getElementById(id).scrollIntoView({
			behavior: "smooth",  // 平滑过渡
block: 'start' // start 上边框  center 中间  end 底部边框 与视窗顶部平齐
}); }) },

  

 // 平滑过渡
posted @ 2023-03-10 11:18  人间春风意  阅读(165)  评论(0编辑  收藏  举报