当前位置:网站首页>El table X-axis direction (horizontal) scroll bar slides to the right by default
El table X-axis direction (horizontal) scroll bar slides to the right by default
2022-07-03 09:58:00 【Misty rain fell on the capital】
Recently, I encountered a strange demand , To be one table When there is too much data , There must be a horizontal scroll bar , The default is near the leftmost , Now, we need it to slide to the right by default , I made a lot of efforts and my own thinking, and finally realized the demand , The two methods are only for reference :
demand :
Very simple. el-table Two columns on the left el-table-column added fixed Fixed on the left , Slide the scroll bar to see the content behind , Now to initialize, slide it to the right .
Method 1: to el-table Add ref='tableList' attribute , Modify its native properties bodyWrapper Inside Of scrollLeft value , Remember to put this.$nextTick in . And add setTimeout , Otherwise there will be dom The problem of rendering , The value cannot be attached .
mounted() {
this.$nextTick(()=>{
// Get it first The width of the table
var widthKK =this.$refs.tableList.bodyWidth
// solve scrollLeft The problem that value cannot be assigned to value
setTimeout(()=>{
this.$refs.tableList.bodyWrapper.scrollLeft=Number(widthKK.replace('px',''))
},1000)// Must be 1000 above To take effect
})
},Be careful : We must add setTimeout And you have to set 1s above , Otherwise, it will not take effect .
Method 2: Don't use vue Of ref, Direct manipulation js Get its elements and directly change its scrollLeft value .
mounted() {
this.$nextTick(()=>{
var widthKK =this.$refs.tableList.bodyWidth
// solve scrollLeft The problem that value cannot be assigned to value
setTimeout(()=>{
document.getElementsByClassName("el-table__body-wrapper")[0].scrollLeft=Number(this.widthKK.replace('px',''))
},1000)// Must be 1000 above To take effect
})
},
Be careful : This method will get all the pages are el-table__body-wrapper The elements of , If your page has multiple tables, pay attention to the appropriate subscript .
Last : If the page has multiple tables , And when you use the first method , It is recommended to use ref Do not take the same value , Otherwise, it will not take effect .
边栏推荐
- Fundamentals of Electronic Technology (III)__ Chapter 1 resistance of parallel circuit
- The cyclic shift of PUCCH in NR channel is generated by MATLAB
- 2.Elment Ui 日期选择器 格式化问题
- Uniapp realizes global sharing of wechat applet and custom sharing button style
- 自動裝箱與拆箱了解嗎?原理是什麼?
- 学历是一张通行证,门票,你有了它,可以踏入更高层次的环境里
- 自动装箱与拆箱了解吗?原理是什么?
- el-table X轴方向(横向)滚动条默认滑到右边
- STM32 general timer 1s delay to realize LED flashing
- 手机都算是单片机的一种,只不过它用的硬件不是51的芯片
猜你喜欢

How does the memory database give full play to the advantages of memory?

对于新入行的同学,如果你完全没有接触单片机,建议51单片机入门

要選擇那種語言為單片機編寫程序呢

Fundamentals of Electronic Technology (III)__ Chapter 1 resistance of parallel circuit

JMX、MBean、MXBean、MBeanServer 入门

JS基础-原型原型链和宏任务/微任务/事件机制

【力扣刷题笔记(二)】特别技巧,模块突破,45道经典题目分类总结,在不断巩固中精进
![[CSDN] C1 training problem analysis_ Part IV_ Advanced web](/img/ee/2e9756cc0e2e6eda83e1b2304c0bd6.png)
[CSDN] C1 training problem analysis_ Part IV_ Advanced web

嵌入式系统没有特别明确的定义

Electronic product design, MCU development, circuit cloning
随机推荐
Fundamentals of Electronic Technology (III)__ Chapter 1 resistance of parallel circuit
Embedded systems are inherently flawed. Compared with the Internet, there are so many holes that it is simply difficult to walk away from
Project cost management__ Plan value_ Earned value_ Relationship among actual cost and Countermeasures
[CSDN] C1 training problem analysis_ Part II_ Web Foundation
Stm32 NVIC interrupt priority management
Do you understand automatic packing and unpacking? What is the principle?
There is no specific definition of embedded system
Serial communication based on 51 single chip microcomputer
Eight working modes of stm32gpio and chip naming rules
单片机学到什么程度能找到工作,这个标准不好量化
自动装箱与拆箱了解吗?原理是什么?
STM32 running lantern experiment - library function version
I think all friends should know that the basic law of learning is: from easy to difficult
新系列单片机还延续了STM32产品家族的低电压和节能两大优势
JMX、MBean、MXBean、MBeanServer 入门
2020-08-23
[graduation successful] [1] - tour [Student Management Information System]
Blue Bridge Cup for migrant workers majoring in electronic information engineering
单片机现在可谓是铺天盖地,种类繁多,让开发者们应接不暇
Project cost management__ Topic of comprehensive calculation