vue-antdUi使用tabs和表格的坑

    使用vue-antd框架,在使用其中的tabs里面套table表格时。会出现一个神奇的bug, 切换tabs时,页面的宽度会增加,出现横向滚动的问题。

    由于是一个二次的开发,我一开始是以为布局中的最外层的盒子没有设置100%布局。于是就设置了一下百分百,但是还是没有解决。这就很哇塞了,困扰了我大概一个多星期。

   后来,在一个偶然的时间,我在页面上调试时,在tabs是外层盒子上,加上了一个绝对定位

即position:absolute,就是这一行样式,完美的解决了。随便在切换,怎么也不会出现横向滚动了。

    后来隐隐约约发现,可能是框架底层,封装table的问题,使用了一个自适应的方法。导致出现的问题。

   总结,在碰到这种宽度自动变大的问题,可以在外层套一个盒子,用定位来解决问题。这个是目前来说,比较好的一个方法。当然这个前提是要设置父级的宽度为100%。

   欢迎大家点击评论和交流!

   

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
你可以使用Ant Design Vue的Table组件和Expandable组件来实现表格嵌套表格的功能。 首先,你需要在你的Vue项目中安装和引入Ant Design Vue和其样式。 然后,你可以使用Ant Design Vue的Table组件来创建你的主表格,并设置Expandable属性为true来启用嵌套表格的功能。 接着,在Table组件的columns属性中,你可以定义主表格的列和嵌套表格的列。对于嵌套表格的列,你可以使用Expandable组件的render属性来自定义每个嵌套行的展示内容。 最后,你可以在Table组件的dataSource属性中设置你的数据,包括主表格和嵌套表格的数据。 下面是一个简单的示例代码: ``` <template> <a-table :columns="columns" :data-source="data" :expandable="expandable"> <template slot="expand" slot-scope="{ record }"> <a-table :columns="nestedColumns" :data-source="record.children"> <template slot="description" slot-scope="{ text }"> <span v-html="text" /> </template> </a-table> </template> </a-table> </template> <script> import { Table, Tag } from 'ant-design-vue'; export default { components: { Table, Tag }, data() { return { expandable: { expandedRowRender: (record) => { return ( <a-table :columns="nestedColumns" :data-source="record.children"> <a-table-column title="Name" dataIndex="name" /> <a-table-column title="Age" dataIndex="age" /> <a-table-column title="Description" dataIndex="description" customRender={(text) => <span v-html="text" />} /> </a-table> ); }, rowExpandable: (record) => record.children.length > 0, }, columns: [ { title: 'Name', dataIndex: 'name', key: 'name', }, { title: 'Age', dataIndex: 'age', key: 'age', }, { title: 'Tags', key: 'tags', dataIndex: 'tags', customRender: (tags) => ( <span> {tags.map((tag) => ( <Tag color="blue" key={tag}> {tag} </Tag> ))} </span> ), }, { title: 'Action', key: 'action', customRender: (text, record) => ( <span> <a>Invite {record.name}</a> <a-divider type="vertical" /> <a>Delete</a> </span> ), }, ], nestedColumns: [ { title: 'Name', dataIndex: 'name', }, { title: 'Age', dataIndex: 'age', }, { title: 'Description', dataIndex: 'description', customRender: (text) => <span v-html="text" />, }, ], data: [ { key: '1', name: 'John Brown', age: 32, tags: ['nice', 'developer'], children: [ { key: '1-1', name: 'Jim Green', age: 42, description: '<strong>Jim Green Description</strong>', }, { key: '1-2', name: 'Joe Black', age: 32, description: '<strong>Joe Black Description</strong>', }, ], }, { key: '2', name: 'Jim Red', age: 42, tags: ['loser'], children: [ { key: '2-1', name: 'Jim Green', age: 42, description: '<strong>Jim Green Description</strong>', }, { key: '2-2', name: 'Joe Black', age: 32, description: '<strong>Joe Black Description</strong>', }, ], }, { key: '3', name: 'Joe Black', age: 32, tags: ['cool', 'teacher'], children: [], }, ], }; }, }; </script> ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值