Ant desgin vue 表格滑动效果:

1.html代码块:

<!-- 表格 -->
        <div class="admin_table_list">
            <a-table :rowkey="id" bordered size="small" :components="components"
                :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }" :columns="columns"
                :data-source="orderList" :pagination="false" :scroll="{x:750 | true, y: 440 }">
                <a slot="seriainumber">{{orderList[index]}}</a>
                <a slot="action" href="javascript:;" slot-scope="text,record" @click="onSee(record)">查看</a>
            </a-table>
        </div>
dsadsadsad  机安静的大萨达 

2.js代码块:

2.1引入一个插件:vue-draggable-resizable

import VueDraggableResizable from 'vue-draggable-resizable'

Vue.component('vue-draggable-resizable', VueDraggableResizable)

2.2 在data里面配置:

export default {
        data() {
            
this.components = {
                header: {
                    cell: (h, props, children) => {
                        const {
                            key,
                            ...restProps
                        } = props
                        console.log('ResizeableTitle', key)
                        const col = this.columns.find(col => {
                            const k = col.dataIndex || col.key
                            return k === key
                        })

                        if (!col || !col.width) {
                            return h('th', {
                                ...restProps
                            }, [...children])
                        }

                        const dragProps = {
                            key: col.dataIndex || col.key,
                            class: 'table-draggable-handle',
                            attrs: {
                                w: 10,
                                x: col.width,
                                z: 1,
                                axis: 'x',
                                draggable: true,
                                resizable: false
                            },
                            on: {
                                dragging: (x, y) => {
                                    col.width = Math.max(x, 1)
                                }
                            }
                        }
                        const drag = h('vue-draggable-resizable', {
                            ...dragProps
                        })
                        return h('th', {
                            ...restProps,
                            class: 'resize-table-th'
                        }, [...children, drag])
                    }
                }
            }
        }
    return {
                pageSizeOptions: ['10', '20', '30', '40', '50'],
                current: 1,
                pageSize: 10,
                total: 0, //默认0条数据
}

2.3 : 注意这里的components在上面html里有用到

2.4: 表格底部滑动配置也在html里面 :pagination="false" :scroll="{x:750 | true, y: 440 }"

记住:表头要给宽度,不然内容少,一屏就能展示出来,也就不存在横向滑动效果了,所以要根据实际情况来

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值