title: UpdateManager.onUpdateFailed header: develop nav: api
sidebar: UpdateManager-onUpdateFailed
解释:当新版本下载失败,会进行回调
方法参数
Function callback
示例
扫码体验
请使用百度APP扫码
代码示例
在 swan 文件中
<view class="container"><view class="card-area"><view class="top-description border-bottom">此api会在旧版小程序在拉到最新包失败时触发</view></view></view>
在 js 文件中
Page({data: { },onLoad() {const updateManager = swan.getUpdateManager();updateManager.onUpdateFailed(function (res) {// 请求完新版本信息的回调console.log("res", res);if(!res.hasUpdate){swan.showModal({title: '更新提示',content: '版本更新失败,请重试',});}});}});
