Skip to content

reactiveComputed

Category
Export Size
288 B
Last Changed
2 months ago

计算响应式对象。与 computed 返回一个 ref 不同,reactiveComputed 返回一个响应式对象。

用法

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

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

state.bar // 'baz'

Type Declarations

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

Source

SourceDocs

Contributors

Anthony Fu
丶远方
Anthony Fu
Robin
sibbng
三咲智子 Kevin Deng
qiang

Changelog

bea31 - fix: computed fn should be ComputedGetter (#4528)
0a9ed - feat!: drop Vue 2 support, optimize bundles and clean up (#4349)
17a72 - fix: unwrap reactive type (#3215)

Released under the MIT License.