reactiveComputed
计算型响应式对象。与 computed 返回一个 ref 不同,reactiveComputed 返回一个响应式对象。
用法
ts
import { reactiveComputed } from '@vueuse/core'
const state = reactiveComputed(() => {
return {
foo: 'bar',
bar: 'baz',
}
})
state.bar // 'baz'类型声明
ts
export type ReactiveComputedReturn<T extends object> = UnwrapNestedRefs<T>
/**
* Computed reactive object.
*/
export declare function reactiveComputed<T extends object>(
fn: ComputedGetter<T>,
): ReactiveComputedReturn<T>