ant design vue table表格radio单选

<a-table
  ref="table"
  size="middle"
  :scroll="{x: 1500}"
  bordered
  rowKey="id"
  :columns="columns"
  :dataSource="dataSource"
  :pagination="ipagination"
  :loading="loading"
  :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange, type: 'radio'}"
  :customRow="customRowFn"
  @change="handleTableChange">
</a-table>
methods:{
data(){
	return {
		selectedRowKeys: [],
		selectionRows: []
	}
},
	onSelectChange(selectedRowKeys, selectionRows) {
   	this.selectedRowKeys = selectedRowKeys
     this.selectionRows = selectionRows
   },
   //点击一条数据
	customRowFn(record) {
	    let that = this
	    return {
	      on: {
	        click: () => {
	          let keys = [];
	          keys.push(record.id);
	          this.selectionRows.push(record);
	          this.selectedRowKeys = keys;
	        }
	      }
	    }
	  }
}
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Ant Design VueTable 组件支持自定义列,你可以在自定义列中添加一个点击事件来实现图片的放大效果。具体步骤如下: 1. 在 Table 的 columns 中添加一个自定义列,如下所示: ```javascript { title: '图片', dataIndex: 'imageUrl', scopedSlots: { customRender: 'imageUrl' } }, ``` 这里的 `scopedSlots` 属性用于定义自定义列的渲染方式。 2. 在 Table 的 `template` 中定义 `customRender` 的具体实现,如下所示: ```html <template> <a-table :columns="columns" :data-source="dataSource"> <template slot="imageUrl" slot-scope="text"> <a @click="showModal(text)"> <img :src="text" style="width: 50px; height: 50px"> </a> </template> </a-table> </template> ``` 这里的 `slot` 属性用于定义自定义列的名称,`slot-scope` 属性用于获取当前行的数据对象。 3. 在 `methods` 中定义 `showModal` 方法,用于显示放大后的图片: ```javascript methods: { showModal(text) { this.imageUrl = text; this.visible = true; }, }, ``` 在 `showModal` 方法中,我们将当前行的图片地址保存到 `imageUrl` 变量中,并将 `visible` 变量设置为 `true`,以显示 `Modal` 弹窗。 4. 在 `template` 中添加 `Modal` 弹窗组件,如下所示: ```html <template> <a-table :columns="columns" :data-source="dataSource"> <template slot="imageUrl" slot-scope="text"> <a @click="showModal(text)"> <img :src="text" style="width: 50px; height: 50px"> </a> </template> </a-table> <a-modal v-model="visible"> <img :src="imageUrl" style="max-width: 100%"> </a-modal> </template> ``` 这里的 `v-model` 属性用于控制 `Modal` 弹窗的显示和隐藏,当 `visible` 变量为 `true` 时,弹窗显示;当 `visible` 变量为 `false` 时,弹窗隐藏。 这样,当用户点击表格中的图片时,就会弹出一个模态框,显示放大后的图片。用户点击模态框外部区域或者关闭按钮,模态框就会关闭,放大后的图片也会随之消失。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值