title: UpdateManager.onCheckForUpdate header: develop nav: api
sidebar: UpdateManager-onCheckForUpdate
解释:当向百度后台请求完新版本信息,会进行回调。
方法参数
Function callback
参数说明
| 属性 | 类型 | 说明 |
|---|---|---|
| hasUpdate | Boolean | 是否有新的版本 |
示例
扫码体验
请使用百度APP扫码
代码示例
- 在 swan 文件中
<view class="container"><view class="card-area"><view class="top-description border-bottom">onCheckForUpdate</view><button type="primary" bindtap="bindOnCheckForUpdate">button</button></view></view>
- 在 js 文件中
Page({data: {},bindOnCheckForUpdate() {const updateManager = swan.getUpdateManager();updateManager.onCheckForUpdate(function (res) {// 请求完新版本信息的回调console.log("res", res.hasUpdate);if(!res.hasUpdate){swan.showModal({title: '更新提示',content: '无可用更新版本',});}});}});
