点击一行并选中(可获取该行数据),改变颜色
<s-table ref="table" rowKey="key" bordered :columns="columns" :data="loadData" showPagination="auto" :customRow="customRow" :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange, type: 'radio' }" > <span slot="serial" slot-scope="text, record, index"> {{ index + 1 }} </span> </s-table>
computed: { rowSelection () { return { selectedRowKeys: this.selectedRowKeys, onChange: this.onSelectChange } } }
customRow (record, index) { return { on: { click: (e) => { console.log(record, index) this.selectedRowKeys = [index] this.selectedRows = [record] } } } }, onSelectChange (selectedRowKeys, selectedRows) { this.selectedRowKeys = selectedRowKeys this.selectedRows = selectedRows },