onRecordAdd 
- Category: 
Events - Relate: 
onRecordAdd - 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 { onRecordAdd, useSelection } from "@qww0302/use-bitable"
import type { IEventCbCtx } from "@lark-base-open/js-sdk"
import { ref } from "vue"
const { tableId } = useSelection()
const ev = ref<IEventCbCtx<[recordId: string]>>()
onRecordAdd(tableId, (e) => {
  ev.value = e
})
</script>
<template>
  <div>
    Try to add records:
    <span v-if="ev">You have added {{ ev.data.length }} record{{ ev.data.length > 1 ? "s" : "" }}. </span>
    <pre>{{ JSON.stringify(ev, null, 2) }}</pre>
  </div>
</template>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Usage 
Type Declarations 
ts
import { type ITable, type IEventCbCtx } from "@lark-base-open/js-sdk"
import { MaybeRefOrGetter } from "vue"
/**
 * Listen to record add event
 *
 * 监听记录添加事件
 *
 * @param table
 * @param callback
 * @returns
 */
export declare function onRecordAdd(
  table: MaybeRefOrGetter<ITable | string | null>,
  callback: (ev: IEventCbCtx<[recordId: string]>) => void,
): {
  off: () => void
  pending: import("vue").Ref<boolean, boolean>
}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