Ant Design of Vue清空a-table中的選中項


用最笨且最直截了當的方法 ,對ant design的table中自帶的rowSelection中selectedRowKeys直接進行綁定。

<div class="content_Table">
  <!-- onSelectInvert: onSelectInvert, -->
    <a-table
      bordered
      :loading="loading"
      :row-selection="{
      	selectedRowKeys: selectedRowKeys,
        onChange: onSelectChange,
      }"
      :data-source="shoppingCar"
      :pagination="shopCarPagination"
      :scroll="{ y: 470 }"
      :row-key="
      (record, index) => {
        return index;
      }
      "
>

在data中初始化selectedRowKeys,然后在方法中直接對selectedRowKeys進行重新賦值操作即可。

export default {
  name: 'BorrowAndReturn',
  components: {
  },
  data () {
    return {
      // table選中項的key
      selectedRowKeys: []
    }
  },
  methods: {
    // 直接給selectedRowKeys重新賦值即可
    clean () {
      this.selectedRowKeys = []
    }
  }
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM