mirror of
https://github.com/element-plus/element-plus.git
synced 2025-08-14 10:00:58 +08:00

* perf: change to import-x * feat: add rules * chore: fix rule * chore: fix * chore: fix * chore: fix * style: `pnpm lint:fix` * Revert "style: `pnpm lint:fix`" This reverts commit db0116a288299c507e3cfc4d7a22e2207265d920. * Revert "chore: fix" This reverts commit 69c82a90c01525e38180be4c21e8ef5602512318. * chore: fix * style: `pnpm lint:fix` * fix: lint * chore: `pnpm format`
63 lines
1.4 KiB
Vue
63 lines
1.4 KiB
Vue
<template>
|
|
<el-table
|
|
ref="singleTableRef"
|
|
:data="tableData"
|
|
highlight-current-row
|
|
style="width: 100%"
|
|
@current-change="handleCurrentChange"
|
|
>
|
|
<el-table-column type="index" width="50" />
|
|
<el-table-column property="date" label="Date" width="120" />
|
|
<el-table-column property="name" label="Name" width="120" />
|
|
<el-table-column property="address" label="Address" />
|
|
</el-table>
|
|
<div style="margin-top: 20px">
|
|
<el-button @click="setCurrent(tableData[1])">Select second row</el-button>
|
|
<el-button @click="setCurrent()">Clear selection</el-button>
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { ref } from 'vue'
|
|
|
|
import type { TableInstance } from 'element-plus'
|
|
|
|
interface User {
|
|
date: string
|
|
name: string
|
|
address: string
|
|
}
|
|
|
|
const currentRow = ref()
|
|
const singleTableRef = ref<TableInstance>()
|
|
|
|
const setCurrent = (row?: User) => {
|
|
singleTableRef.value!.setCurrentRow(row)
|
|
}
|
|
const handleCurrentChange = (val: User | undefined) => {
|
|
currentRow.value = val
|
|
}
|
|
const tableData: User[] = [
|
|
{
|
|
date: '2016-05-03',
|
|
name: 'Tom',
|
|
address: 'No. 189, Grove St, Los Angeles',
|
|
},
|
|
{
|
|
date: '2016-05-02',
|
|
name: 'Tom',
|
|
address: 'No. 189, Grove St, Los Angeles',
|
|
},
|
|
{
|
|
date: '2016-05-04',
|
|
name: 'Tom',
|
|
address: 'No. 189, Grove St, Los Angeles',
|
|
},
|
|
{
|
|
date: '2016-05-01',
|
|
name: 'Tom',
|
|
address: 'No. 189, Grove St, Los Angeles',
|
|
},
|
|
]
|
|
</script>
|