antdui table的行 操作————antd-vue

        <a-table 
 
          :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange, columnWidth: 40 }"
          :columns="columns" 
          :data-source="LXRlist" 
          :scroll="{ x: 1600, y:selectShow?'calc(100vh - 376px)':'calc(100vh - 276px)' }"
          :pagination="false"
          @change="handleTableChange"
          size="small"
          class="custom-table"
          :customRow='LXRclick'
        >

:customRow=‘LXRclick’ 写一个事件

    LXRclick(record, index) {
      return {
        on: {
            click: () => {
                console.log(record,index);
                this.OpenDetail(record)
            }
	        dblclick: (event) => {},//双击
	        contextmenu: (event) => {},
	        mouseenter: (event) => {},  // 鼠标移入行
	        mouseleave: (event) => {} // 鼠标移出行
            
        }
      }
	  },
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
vue3 antdvue 中,要对 a-table 中的合计,可以利用 a-table 中的 footer 属性和 scoped slot 的方式来实现。 为了得到每一中需要合计的值,需要先将数据进处理。 首先,需要在 a-table 中设置 footer 属性为 true,这样就会生成表格的 footer 部分。 然后,可以利用 scoped slot 来自定义 footer 的内容。在 slot-scope 中,可以获取到表格中的所有数据,包括每一中的数据。可以遍历每一的数据,计算需要合计的值,并将结果显示在 footer 中。 下面是实现的代码示例: ``` <template> <a-table :columns="columns" :data-source="data" :footer="true"> <template v-slot:footer> <a-table-tfoot> <a-table-cell v-for="col in columns" :key="col.key"> <template v-if="col.key === 'total'"> {{ getFooterTotal(col.key) }} </template> <template v-else> {{ col.title }} </template> </a-table-cell> </a-table-tfoot> </template> </a-table> </template> <script> export default { data() { return { columns: [ { title: 'Name', dataIndex: 'name', key: 'name' }, { title: 'Age', dataIndex: 'age', key: 'age' }, { title: 'Address', dataIndex: 'address', key: 'address' }, { title: 'Total', key: 'total' }, ], data: [ { name: 'John', age: 28, address: 'New York', total: 100 }, { name: 'Jane', age: 32, address: 'London', total: 200 }, { name: 'Bob', age: 42, address: 'Paris', total: 300 }, ], }; }, methods: { getFooterTotal(key) { let total = 0; this.data.forEach((item) => { total += item[key]; }); return total; }, }, }; </script> ``` 在这个示例中,我们定义了一个 a-table ,包含了四列数据:Name、Age、Address 和 Total。其中,Total 列需要对其下面的每一合计。 我们通过设置 footer 属性为 true,确保能够生成表格的 footer 部分。接着,我们可以利用 scoped slot 来自定义 footer 的内容。 在 footer 模板中,我们首先定义了一个 a-table-tfoot 元素,表示 footer 中要显示的。 然后,我们遍历每一列数据,如果是 Total 列,就调用 getFooterTotal 方法来计算合计值。这个方法遍历每一数据,将 Total 列的值累加到 total 中。 最后,我们将结果返回给 footer 模板,以显示在表格的 footer 中。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值