target 触发滚动的对象 string
<template>
Scroll down to see the bottom-right button.
<el-backtop target=".page-component__scroll .el-scrollbar__wrap"></el-backtop>
</template>
官网对于target属性的介绍,但是使用时如果按照上方代码运行不出来,
在经过测试后,我将target属性用来选择滚动的对象就可使用,不写则默认在网页上实现回到顶部效果。
不写target属性
<template>
<div>
<el-backtop ></el-backtop>
<p v-for="i in 50" :key="i">占一行</p>
</div>
</template>
利用target属性选择滚动对象
<template>
<div class="ele">
<el-backtop target='.area'></el-backtop>
<div class="area" style="width: 100%;height: 200px;overflow: auto;">
<template>
<div style="width: 100%;height: 600px;" class="area1">
<p v-for="i in 50" :key="i">占一行</p>
</div>
</template>
</div>
</div>
</template>
这样就会在.area区域的滚动条滚动时实现回到顶部效果