useSelection 
- Category: 
Composables - Relate: 
onSelectionChange - Dependencies: 
@lark-base-open/js-sdk - Last Changed: yesterday
 
提示
该函数需要在一个多维表格中使用,请将本文档作为一个插件在多维表格上使用以查看演示。
演示 
显示演示代码
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
用法 
useSelection 是响应式的当前选中项,它实时根据用户选中对象的变化更新。
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
类型声明 
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, string | null>
  recordId: import("vue").Ref<string | null, string | null>
  fieldId: import("vue").Ref<string | null, string | null>
  viewId: import("vue").Ref<string | null, string | null>
  tableId: import("vue").Ref<string | null, 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