首先组件上加ref,注意ref不能和v-if一起用
在mounted钩子函数里获取ref,塞到data里
this.dom = this.$refs.table
再定义函数
changeScroll(index){
this.$nextTick(()=>{
this.dom.$el.querySelector('.ant-table-body').scrollTop = index*20
})
},
大家可以自由发挥,通过打印dom.$el,再使用querySelector(’#xxx’)获取对应的Dom节点,就可以都修改了
注意要用
$nextTick
包着