mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-14 20:19:34 +01:00
49 lines
979 B
Vue
49 lines
979 B
Vue
<script setup lang="ts">
|
|
const people = [{
|
|
id: 1,
|
|
name: 'Lindsay Walton',
|
|
title: 'Front-end Developer',
|
|
email: 'lindsay.walton@example.com',
|
|
role: 'Member'
|
|
}, {
|
|
id: 2,
|
|
name: 'Courtney Henry',
|
|
title: 'Designer',
|
|
email: 'courtney.henry@example.com',
|
|
role: 'Admin'
|
|
}, {
|
|
id: 3,
|
|
name: 'Tom Cook',
|
|
title: 'Director of Product',
|
|
email: 'tom.cook@example.com',
|
|
role: 'Member'
|
|
}, {
|
|
id: 4,
|
|
name: 'Whitney Francis',
|
|
title: 'Copywriter',
|
|
email: 'whitney.francis@example.com',
|
|
role: 'Admin'
|
|
}, {
|
|
id: 5,
|
|
name: 'Leonard Krasner',
|
|
title: 'Senior Designer',
|
|
email: 'leonard.krasner@example.com',
|
|
role: 'Owner'
|
|
}]
|
|
|
|
function select (row) {
|
|
const index = selected.value.findIndex((item) => item.id === row.id)
|
|
if (index === -1) {
|
|
selected.value.push(row)
|
|
} else {
|
|
selected.value.splice(index, 1)
|
|
}
|
|
}
|
|
|
|
const selected = ref([people[1]])
|
|
</script>
|
|
|
|
<template>
|
|
<UTable v-model="selected" :rows="people" @select="select" />
|
|
</template>
|