<template>
<div class="video" ref="scro">
<button @click="test">点击</button>
<p v-for="item in 100" :key="item">测试{{item}}</p>
<div ref="btn">测试111</div>
<button @click="go">返回</button>
</div>
</template>
<script>
export default {
methods: {
test () {
console.log(this.$refs.btn.offsetTop)
this.$refs.scro.scrollTop = this.$refs.btn.offsetTop
},
go () {
this.$refs.scro.scrollTop = 100
}
}
}
</script>
<style scoped lang="scss">
.video {
height: 300px;
overflow: auto;
}
</style>