useData
- Category:
Composables
- Relate:
getData
setData
- Dependencies:
@lark-base-open/js-sdk
- Last Changed: 5 months 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 { useData } from "@qww0302/use-bitable"
import { ref } from "vue"
const { data } = useData()
const i = ref("test")
// const data = ref()
const click = () => {
data.value = i.value
}
</script>
<template>
<div>
<input v-model="i">
<button @click="click">
click
</button>
<p>{{ data }}</p>
</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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Type Declarations
ts
import { MaybeRefOrGetter, type Ref } from "vue"
export interface Serializer<T = unknown, R = unknown> {
read: (raw: R) => T
write: (data: T) => R
}
/**
* useData options
*
* useData 配置项
*/
interface useDataOptions<T = unknown, R = unknown> {
/**
* Serialization
*
* 序列化
*/
serializer?: Serializer<T, R>
/**
* Whether to shallowly watch for changes
*
* 是否浅层监听变化
*
* @default false
*/
shallow?: boolean
}
/**
* Reactive Bitable data
*
* 响应式的 Bitable 数据
*
* @param options
* @returns
*/
export declare function useData<T = unknown, R = T>(
key: MaybeRefOrGetter<string>,
defaults?: T,
options?: useDataOptions<T, R>,
): {
data: Ref<T>
pending: Ref<boolean>
}
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
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