天天看點

ant design vue 設定表格選擇框,全選按鈕選不全

左側勾選框 你需要配置 :row-selection="rowSelection"

<a-table
      :pagination="false"
      size="small"
      :row-selection="rowSelection"
      :columns="columns"
      :data-source="data"
      :scroll="{ x: 1100 }"
      rowKey="id"   //全選是根據這個id判斷的,一定要有
    />//id不要動态綁定,要不然不能全選1.      

函數内有兩個回調 

1. const rowSelection = {
      onChange: (selectedRowKeys: Key[], selectedRows) => { 
        //第一個參數控制選不選中,第二個參數是選中清單的資料的集合
        console.log(
          selectedRows
        );
      },
      getCheckboxProps: (record) => ({   
        disabled: record.releaseState === "ONLINE", //控制禁用那個按鈕
        releaseState: record.releaseState,
      }),
    };      

繼續閱讀