记录antd的table表格合并行、元素是组件和绑定事件

 用途:antd的table合并单元格时,需要对单元格的元素改为html元素,同时添加一些事件行为。

绑定事件需要使用: onClick={() => this.DetailAdd(row)}

{
          title: '仪器',
          align: "center",
          dataIndex: 'instrument',
          customRender: (value, row, index) => {
            var vm = this
            // var child = vm.$createElement("a", {
            //   domProps: {
            //     innerHTML: value
            //   },
            //   on: {
            //     //左击
            //     click: function () {
            //       if (vm.editModal) {
            //         vm.DetailAdd(row);
            //       } else {
            //       }
            //     },
            //     //右击
            //     contextmenu: function (event) {
            //       if (vm.editModal) {
            //         vm.showTips(row);
            //       } else {
            //       }
            //       // 阻止浏览器的默认行为   
            //       event.preventDefault();
            //     }
            //   }
            // });
            var childrenVal
            childrenVal = (
              <div>
                <a-popover trigger="click">
                  <div slot="content" >
                    <a-button type="primary" onClick={() => this.DetailAdd(row)}>新增子项目</a-button>
                    <a-button type="primary" style="margin-left:8px;background-color:#8bc34a;border-color:#8bc34a">调整仪器</a-button>
                    <a-button type="danger" style="margin-left:8px;background-color:#ff7875;">删除仪器</a-button>
                  </div>
                  <a type="primary">
                    {value}
                  </a>
                </a-popover>
              </div >
            )
            const obj = {
              children: childrenVal,
              attrs: {}
            };
            const _row = this.instrumentRowArr[index];
            obj.attrs = {
              rowSpan: _row,
            };
            return obj;
          },
        },

  参考:Antd表格customRender与scopedSlots同时使用_antd customrender-CSDN博客

  • 10
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值