mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-03 04:27:41 +08:00
15 lines
391 B
TypeScript
15 lines
391 B
TypeScript
|
import type { UnwrapRef } from 'vue';
|
||
|
import { reactive, toRef } from 'vue';
|
||
|
|
||
|
/**
|
||
|
* Reactively pick fields from a reactive object
|
||
|
*
|
||
|
* @see https://vueuse.js.org/reactivePick
|
||
|
*/
|
||
|
export function reactivePick<T extends object, K extends keyof T>(
|
||
|
obj: T,
|
||
|
...keys: K[]
|
||
|
): { [S in K]: UnwrapRef<T[S]> } {
|
||
|
return reactive(Object.fromEntries(keys.map(k => [k, toRef(obj, k)]))) as any;
|
||
|
}
|