mirror of
https://github.com/directus/directus.git
synced 2026-02-03 03:34:56 -05:00
Use Sync
function useSync<T, K extends keyof T>(
props: T,
key: K,
emit: (event: string, ...args: any[]) => void
): Ref<Readonly<T[K]>>;
Small utility composition that allows you to easily setup the two-way binding with the prop:
// Before
const _options = computed({
get() {
return props.options;
},
set(val) {
emit('update:options', val);
},
});
// after
const _options = useSync(props, 'options', emit);