跳到主要内容

useMemory

分类
导出大小
538 B
上次更改
3 个月前

响应式内存信息。

演示

您的浏览器不支持性能内存 API

用法

ts
import { 
useMemory
} from '@vueuse/core'
const {
isSupported
,
memory
} =
useMemory
()

类型声明

ts
/**
 * Performance.memory
 *
 * @see https://mdn.org.cn/en-US/docs/Web/API/Performance/memory
 */
export interface MemoryInfo {
  /**
   * The maximum size of the heap, in bytes, that is available to the context.
   */
  readonly 
jsHeapSizeLimit
: number
/** * The total allocated heap size, in bytes. */ readonly
totalJSHeapSize
: number
/** * The currently active segment of JS heap, in bytes. */ readonly
usedJSHeapSize
: number
[
Symbol
.
toStringTag
]: "MemoryInfo"
} export interface UseMemoryOptions extends UseIntervalFnOptions {
interval
?: number
} /** * Reactive Memory Info. * * @see https://vueuse.org.cn/useMemory * @param options * * @__NO_SIDE_EFFECTS__ */ export declare function
useMemory
(
options
?: UseMemoryOptions): {
isSupported
:
ComputedRef
<boolean>
memory
:
Ref
<MemoryInfo | undefined, MemoryInfo | undefined>
} export type
UseMemoryReturn
=
ReturnType
<typeof
useMemory
>

来源

源代码演示文档

贡献者

Anthony Fu
Jelf
SerKo
Anthony Fu
webfansplz

更新日志

v13.6.0
d32f8 - refactor: 为所有纯函数添加 @__NO_SIDE_EFFECTS__ 注释 (#4907)
0a9ed - feat!: 放弃对 Vue 2 的支持,优化打包并清理 (#4349)

根据 MIT 许可证发布。