Skip to content

useMemory

类别
导出体积
538 B
上次更改
2 months ago

响应式内存信息。

示例

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

使用方法

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

类型声明

ts
/**
 * Performance.memory
 *
 * @see https://developer.mozilla.org/en-US/docs/Web/API/Performance/memory
 */
export interface MemoryInfo {
  /**
   * 上下文可用的堆的最大大小(以字节为单位)。
   */
  readonly 
jsHeapSizeLimit
: number
/** * 分配的堆的总大小(以字节为单位)。 */ readonly
totalJSHeapSize
: number
/** * 当前活动的 JS 堆段大小(以字节为单位)。 */ readonly
usedJSHeapSize
: number
[
Symbol
.
toStringTag
]: "MemoryInfo"
} export interface UseMemoryOptions extends UseIntervalFnOptions {
interval
?: number
} /** * 响应式内存信息 * * @see https://vueuse.org/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

更新日志

d32f8 - refactor: add @__NO_SIDE_EFFECTS__ annotations to all pure functions (#4907)
0a9ed - feat!: drop Vue 2 support, optimize bundles and clean up (#4349)