package list from viandwi24
This commit is contained in:
16
composables/useSyncProps.ts
Normal file
16
composables/useSyncProps.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { WritableComputedRef } from 'vue'
|
||||
|
||||
export const useSyncProps = <T>(
|
||||
props: any,
|
||||
key: string,
|
||||
emit: any
|
||||
): WritableComputedRef<T> => {
|
||||
return computed({
|
||||
get() {
|
||||
return props[key]
|
||||
},
|
||||
set(value) {
|
||||
emit(`update:${key}`, value)
|
||||
},
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user