小程序开放平台

文档中心
暂无目录

xhs.onCheckForUpdate

更新时间:2025-04-10 15:29:10

以Promise风格调用: 不支持

监听向小红书后台请求检查更新结果事件。小红书在小程序每次启动(不包括热启动)时自动检查更新,不需由开发者主动触发。

参数

function callback

参数

属性
类型
说明
hasUpdateboolean是否有新版本

实例代码

App({
  onLaunch() {
    // 此处仅为效果展示,建议在app.js中的OnLaunch()中调用
    const updateManager = xhs.getUpdateManager();
    updateManager.onCheckForUpdate((res) => {
      xhs.showToast({
        title: (res.hasUpdate ? "有" : "无") + "可用更新版本",
        icon: "none",
      });
    });
  },
});
该文档是否对您有帮助?