element ui table 添加數(shù)據(jù)行后滾動條滾動到對應(yīng)的行頭或行尾問題滾動到第一行:this.$refs.table.bodyWrapper.scrollTop =0;滾動到最后一行:this.$refs.table.bodyWrapper.scrollTop =this.$refs.table.bodyWrapper.scrollHeight;在網(wǎng)上看到上面這種解決方案,但是自己實驗了一下,發(fā)現(xiàn)不行,請問是什么原因?------------------------------------------------------分界線-----------------------------------------------后續(xù)進展:我改成this.$nextTick(() => {
let scrollHeight = this.$refs.table.bodyWrapper.scrollHeight
this.$refs.table.bodyWrapper.scrollTop = scrollHeight
})就能設(shè)置成功了,但總是滾動到離底部差一點的地方。我查了一下,bodyWrapper.scrollHeight等于1256,max-height是659,所以一般設(shè)置成1256-659=597就能保證滾動條滾動到底部,但是我設(shè)置完成之后打印出來的bodyWrapper.scrollTop是567,所以總是滾動到離底部差一點的地方,這是為何呢?
1 回答

慕俠2389804
TA貢獻1719條經(jīng)驗 獲得超6個贊
沒用過,具體要看你怎么寫的:
1.<el-table ref="table"> // 要有ref屬性 2. this.$refs.table.bodyWrapper.scrollTop //這句話你寫在哪里嗎 要確保this.$refs.table獲取到<el-table
- 1 回答
- 0 關(guān)注
- 5588 瀏覽
添加回答
舉報
0/150
提交
取消