当前位置:网站首页>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 .
边栏推荐
- Electronic product design
- Working mode of 80C51 Serial Port
- Runtime. getRuntime(). GC () and runtime getRuntime(). The difference between runfinalization()
- 手机都算是单片机的一种,只不过它用的硬件不是51的芯片
- The third paper of information system project manager in soft examination
- 自动装箱与拆箱了解吗?原理是什么?
- 51 MCU tmod and timer configuration
- Vector processor 9_ Basic multilevel interconnection network
- 当你需要使用STM32某些功能,而51实现不了时, 那32自然不需要学
- [graduation successful] [1] - tour [Student Management Information System]
猜你喜欢
[male nanny style] teach you to open the first wechat applet
当你需要使用STM32某些功能,而51实现不了时, 那32自然不需要学
对于新入行的同学,如果你完全没有接触单片机,建议51单片机入门
IDEA远程断点调试jar包项目
There is no specific definition of embedded system
Mobile phones are a kind of MCU, but the hardware it uses is not 51 chip
Intelligent home design and development
Windows下MySQL的安装和删除
An executable binary file contains more than machine instructions
CEF下载,编译工程
随机推荐
Runtime. getRuntime(). GC () and runtime getRuntime(). The difference between runfinalization()
开学实验里要用到mysql,忘记基本的select语句怎么玩啦?补救来啦~
应用最广泛的8位单片机当然也是初学者们最容易上手学习的单片机
Working mode of 80C51 Serial Port
UCI and data multiplexing are transmitted on Pusch - placement of data and UCI positions (Part III)
UCI and data multiplexing are transmitted on Pusch (Part VI) -- LDPC coding
Runtime.getRuntime().gc() 和 Runtime.getRuntime().runFinalization() 的区别
Education is a pass and ticket. With it, you can step into a higher-level environment
There is no shortcut to learning and development, and there is almost no situation that you can learn faster by leading the way
Sending and interrupt receiving of STM32 serial port
Liquid crystal display
Hal library sets STM32 clock
Project cost management__ Cost management technology__ Article 6 prediction
How does the memory database give full play to the advantages of memory?
SSB Introduction (PbCH and DMRs need to be supplemented)
51 MCU tmod and timer configuration
UCI and data multiplexing are transmitted on Pusch - Part I
没有多少人能够最终把自己的兴趣带到大学毕业上
el-table X轴方向(横向)滚动条默认滑到右边
[combinatorics] Introduction to Combinatorics (context of combinatorics | skills of combinatorics | thought of combinatorics 1: one-to-one correspondence)