Skip to content

reactiveComputed

计算反应式对象。reactiveComputed 返回一个响应式对象,而不是像 computed 那样返回引用。

¥Computed reactive object. Instead of returning a ref that computed does, reactiveComputed returns a reactive object.

用法

¥Usage

ts
import { reactiveComputed } from '@vueuse/core'

const state = reactiveComputed(() => {
  return {
    foo: 'bar',
    bar: 'baz',
  }
})

state.bar // 'baz'

类型声明

typescript
/**
 * Computed reactive object.
 */
export declare function reactiveComputed<T extends object>(
  fn: ComputedGetter<T>,
): UnwrapNestedRefs<T>

源代码

源代码文档

变更日志

v12.6.0 on 2/14/2025
bea31 - fix: computed fn should be ComputedGetter (#4528)

VueUse v12.7 中文网 - 粤ICP备13048890号