<template>
<div class="home">
滑动滚轮然后给我滚回来
<el-backtop target=".home">
<div class="back">
滚到顶部
</div>
</el-backtop>
<h1>滚</h1>
<h1>滚</h1>
<h1>滚</h1>
<h1>滚</h1>
<h1>滚</h1>
<h1>滚</h1>
<h1>滚</h1>
<h1>滚</h1>
<h1>滚</h1>
<h1>滚</h1>
<h1>滚</h1>
<h1>滚</h1>
<h1>滚</h1>
<h1>滚</h1>
<h1>滚</h1>
<h1>滚</h1>
<h1>滚</h1>
<h1>滚</h1>
<h1>滚</h1>
<h1>滚</h1>
<h1>滚</h1>
</div>
</template>
<script>
export default {
name: 'home',
}
</script>
<style>
.home {
border: 1px solid red;
height: 500px;//注意,给个高度才有效果
overflow-y: scroll;
}
.back {
background-color: red;
color: #fff;
border-radius: 20px;
}
</style>
注意事项
- target=".home"
- height: 500px;//注意,给个高度才有效果
- overflow-y: scroll;