How does el-scrollbar scroll to the anchor?

el-scrollbar is used to look good, and the scroll bar is hidden
, but now there is a problem that you can"t scroll to the anchor point because you can"t scroll to the anchor point, and window.scrollTo can"t either

.

the height of el-scrollbar must be set before you can use scrollTop. The content area is a fixed height, which is very ugly.

what I want is the effect of clicking direct-sharpid to reach the anchor

Jul.06,2021

< template >
< div class= "test" >

<a href="javascript:void(0)" @click="AnchorLinkTo('id')"></a>
<el-scrollbar ref="myScrollbar" style="height: 300px; width: 500px;">
  <div>
    

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

<p ref="id">

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

sdfsdfsd

</div> </el-scrollbar>

< / div >
< / template >
< script >
export default {
name: 'test',
data () {

return {}

},
methods: {

AnchorLinkTo (ref) {
  this.$refs['myScrollbar'].wrap.scrollTop = this.$refs['' + ref].offsetTop
}

}
}
< / script >

Menu