onSelectionChange 
- Category: 
Events - Relate: 
onSelectionChange - Dependencies: 
@lark-base-open/js-sdk - Last Changed: yesterday
 
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 { onSelectionChange } from "@qww0302/use-bitable"
import { ref } from "vue"
interface History {
  tableId: string
  viewId: string
  recordId: string
  fieldId: string
  baseId: string
  time: string
}
const history = ref<History[]>([])
onSelectionChange((e) => {
  history.value.push({
    ...e,
    time: new Date().toLocaleTimeString(),
  })
})
</script>
<template>
  <div class="tip custom-block">
    <p class="cuatom-block-title">
      TIP
    </p>
    <p>Choose different table, view or cell.</p>
  </div>
  <p>Select history: </p>
  <div style="overflow: auto;max-height: 200px;">
    <ul>
      <li
        v-for="(h, index) in history.slice().reverse()"
        :key="index"
      >
        <p>Time: {{ h.time }}</p>
        <p>Table: {{ h.tableId }}</p>
        <p>View: {{ h.viewId }}</p>
        <p>Record: {{ h.recordId }}</p>
        <p>Field: {{ h.fieldId }}</p>
        <p>Base: {{ h.baseId }}</p>
      </li>
    </ul>
  </div>
</template>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Type Declarations 
ts
import { Selection } from "@lark-base-open/js-sdk"
/**
 * Listen to selection change
 *
 * 监听选中项变化
 *
 * @param callback
 * @returns
 */
export declare function onSelectionChange(
  callback: (e: Selection) => void,
): () => void1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12