小程序开放平台

文档中心
基础
路由
跳转
转发
界面
网络
支付
数据缓存
媒体
位置
开放接口
设备
剪贴板
网络
电话
内存
onMemoryWarning
offMemoryWarning
扫码
屏幕
XHSML
性能
第三方平台
文件
数据分析
画布

xhs.offMemoryWarning

开发
>
JS API
>
设备
>
内存
>
offMemoryWarning
>
更新时间:2025-04-11 19:01:42

取消监听内存不足告警事件。

参数

function callback

内存不足告警事件的回调函数删除线

实例代码

// 定义内存告警回调函数
function onMemoryWarningCallback(res) {
  console.log('内存告警触发:', res);
  if (res.level !== undefined) {
    console.log('内存告警等级:', res.level); // 仅 Android 有此字段
  }
}

// 开始监听内存不足告警事件
xhs.onMemoryWarning(onMemoryWarningCallback);

// 取消监听内存不足告警事件
xhs.offMemoryWarning(onMemoryWarningCallback);

console.log('已取消内存不足告警事件的监听');
该文档是否对您有帮助?