跳到主要内容

reactiveComputed

分类
导出大小
288 B
上次更改
7 个月前

计算型响应式对象。与 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
>

来源

源码文档

贡献者

Anthony Fu
Robin
Anthony Fu
NoiseFan
sibbng
三咲智子 Kevin Deng
qiang

更新日志

v13.1.0
c1d6e - feat(shared): 确保返回类型存在 (#4659)
v12.6.0
bea31 - 修复: computed 函数应为 ComputedGetter (#4528)
0a9ed - feat!: 放弃对 Vue 2 的支持,优化打包并清理 (#4349)
v10.3.0
17a72 - 修复: 解包响应式类型 (#3215)

根据 MIT 许可证发布。