useSelection
- Category:
Composables
- Relate:
onSelectionChange
- Dependencies:
@lark-base-open/js-sdk
- Last Changed: 2 weeks ago
Notice
This function needs to use in Base, please use this website as a plugin in a Base to see the demo.
Demo
Show demo code
vue
<script setup lang="ts">
import { useSelection } from "@qww0302/use-bitable"
const {
baseId,
recordId,
fieldId,
viewId,
tableId,
} = useSelection()
</script>
<template>
<!-- Yes, this is the simplified `Develop tool` plugin without copy function -->
<p>tableId: {{ tableId ?? "null" }}</p>
<p>viewId: {{ viewId ?? "null" }}</p>
<p>fieldId: {{ fieldId ?? "null" }}</p>
<p>recordId: {{ recordId ?? "null" }}</p>
<p>baseId: {{ baseId ?? "null" }}</p>
</template>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Usage
useSelection
is a reactive current selection, which is updated in real time according to the change of the user's selected object.
ts
import { useSelection } from "@qww0302/use-bitable"
const {
baseId,
recordId,
fieldId,
viewId,
tableId,
} = useSelection()
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
Type Declarations
ts
import { Selection } from "@lark-base-open/js-sdk"
interface useSelectionOptions {
onChanged?: (selection: Selection) => void
}
/**
* Reactive bitable selection
*
* 响应式的bitable当前选中项
*
* @param options
*/
export declare function useSelection(options?: useSelectionOptions): {
baseId: import("vue").Ref<string | null>
recordId: import("vue").Ref<string | null>
fieldId: import("vue").Ref<string | null>
viewId: import("vue").Ref<string | null>
tableId: import("vue").Ref<string | null>
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18