<template>
<div id="app" ref="scrollTop0">
<div class="div-style">
<div
v-for="(item, index) in DataView"
:key="index"
@click="clickToItem(`${item.name}${index}`)"
>
{
{ item.name }}
</div>
<div @click="clickToItem('top')">返回顶部</div>
</div>
<div>12345</div>
<div>12345</div>
<div>12345</div>
<div>12345</div>
<div>12345</div>
<div>12345</div>
<div>12345</div>
<div>12345</div>
<div>12345</div>
<div>12345</div>
<div>12345</div>
<div>12345</div>
<div style="margin-top: 30px">
<div
class="div-height"
ele.scrollIntoView()返回顶部
![](https://img-home.csdnimg.cn/images/20240711042549.png)