给<a-table></a-table>的每一行绑定按钮

在a-table标签体内写入

     <span slot="tags" slot-scope="text, tags, index">
          <a-button size="small" @click="edit(text, tags, index)">编辑</a-button>
          <a-button size="small" style="margin-left: 10px">删除</a-button>
        </span>

在columns: []配置项中

 columns: [
        {
          title: '操作',
          align: 'center',
          dataIndex: 'tags',
          key: 'tags',
          scopedSlots: { customRender: 'tags' },
        },
      ],

注意:columns中的dataIndex: 'tags'要和slot="tags"的tags保持一致

posted @ 2023-01-19 19:53  你笑的好瓜  阅读(196)  评论(0)    收藏  举报