Skip to content

reactiveComputed

类别
导出体积
288 B
上次更改
5 months ago

响应式计算对象。与 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
>
/** * 计算响应式对象。 */ export declare function
reactiveComputed
<
T
extends object>(
fn
:
ComputedGetter
<
T
>,
):
ReactiveComputedReturn
<
T
>

源码

源码文档

贡献者

Anthony Fu
一纸忘忧
Robin
Anthony Fu
sibbng
三咲智子 Kevin Deng
qiang

更新日志

c1d6e - feat(shared): ensure return types exists (#4659)
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)