直接上代码,简单粗暴

<template>
	<div>
      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange,type:'radio'}"
        tableLayout="fixed"
        width='80%'
        @change="handleTableChange"
        class="j-table-force-nowrap"
        >
      </a-table>
     </div>
</template>
export default {
	 data () {
	 	return{
	 		selectedRowKeys:[],
        	selectedRows:[],
	 	}
	 },
	 methods:{
	 //选中状态改变
	 	onSelectChange(selectedRowKeys, selectedRows){
	       this.selectedRowKeys = selectedRowKeys
	       this.selectedRows = selectedRows
	     },
	     // 清空选中
	      clearChecked(){
	      	this.selectedRowKeys = []
      		this.selectedRows = []
	      }
	 }
}

ok~

Logo

前往低代码交流专区

更多推荐