reactiveOmit
Reactively omit fields from a reactive object.
Usage
import { reactiveOmit } from '@vueuse/core'
const obj = reactive({
x: 0,
y: 0,
elementX: 0,
elementY: 0,
})
const picked = reactiveOmit(obj, 'x', 'elementX') // { y: number, elementY: number }
import { reactiveOmit } from '@vueuse/core'
const obj = reactive({
x: 0,
y: 0,
elementX: 0,
elementY: 0,
})
const picked = reactiveOmit(obj, 'x', 'elementX') // { y: number, elementY: number }
Scenarios
Selectively passing props to child
<script setup>
import { reactiveOmit } from '@vueuse/core'
const props = defineProps({
value: {
default: 'value',
},
color: {
type: String,
},
font: {
type: String,
}
})
const childProps = reactiveOmit(props, 'value')
</script>
<template>
<div>
<!-- only passes "color" and "font" props to child -->
<ChildComp v-bind="childProps" />
</div>
</template>
<script setup>
import { reactiveOmit } from '@vueuse/core'
const props = defineProps({
value: {
default: 'value',
},
color: {
type: String,
},
font: {
type: String,
}
})
const childProps = reactiveOmit(props, 'value')
</script>
<template>
<div>
<!-- only passes "color" and "font" props to child -->
<ChildComp v-bind="childProps" />
</div>
</template>
Type Declarations
/**
* Reactively omit fields from a reactive object
*
* @see https://vueuse.js.org/reactiveOmit
*/
export declare function reactiveOmit<T extends object, K extends keyof T>(
obj: T,
...keys: K[]
): Omit<T, K>
/**
* Reactively omit fields from a reactive object
*
* @see https://vueuse.js.org/reactiveOmit
*/
export declare function reactiveOmit<T extends object, K extends keyof T>(
obj: T,
...keys: K[]
): Omit<T, K>
Source
Contributors
Anthony Fu
qiang