x-extends / vxe-table

Vxe table 的表格组件
https://vxetable.cn
MIT License
7.61k stars 1.05k forks source link

vxe-grid 自定义模板,怎么添加事件 #71

Closed maxmeng93 closed 5 years ago

maxmeng93 commented 5 years ago

描述 Describe

    <vxe-grid
      stripe
      highlight-hover-row
      border
      resizable
      auto-resize
      :loading="loading"
      :columns="columns"
      :pager-config="pagerConfig"
      :data.sync="tableData"
      @current-page-change="(currentPage) => pagerChange({currentPage})"
      @page-size-change="(pageSize) => pagerChange({pageSize})">
    </vxe-grid>
this.columns = [
        { type: 'index', width: 40 },
        { label: '编号', prop: 'code' },
        { label: '名称', prop: 'name' },
        { label: '别名', prop: 'alias' },
        { label: '系列', prop: 'seriesName' },
        { label: '状态', prop: 'status', formatter: function ({ cellValue }) { return formatter(basic.status, cellValue); } },
        { label: '创建人', prop: 'creatorName' },
        { label: '创建时间', prop: 'createDate' },
        { label: '修改人', prop: 'changerName' },
        { label: '修改时间', prop: 'changeDate' },
        { label: '作废人', prop: 'cancelName' },
        { label: '作废时间', prop: 'cancelDate' },
        {
          label: '操作',
          prop: 'actions',
          slots: {
            default: ({ row, rowIndex }) => {
              let actions = [];
              if (row.status === 1 && this.editIndex !== rowIndex) {
                actions = [
                  <a>删除</a>,
                  <a>修改</a>
                ];
              }
              if (this.editIndex === rowIndex) {
                actions = [
                  <a>保存</a>,
                  <a>退出</a>
                ];
              }
              return [
                <span class="table-actions">
                  {actions}
                </span>
              ];
            }
          }
        }
      ];

如何在删除,保存等按钮上添加vue事件呢?

请提供能重现问题的链接(jsfiddlecodepenjsrun) Expected behavior

请填写以下版本信息 please complete the following information

xuliangzhan commented 5 years ago

这个你得看 jsx 的文档 demo