taro icon indicating copy to clipboard operation
taro copied to clipboard

小程序版本升级检查无效

Open shwangson opened this issue 4 years ago • 3 comments

相关平台

微信小程序

复现仓库

https://gitee.com/ 小程序基础库: 2.14.4 使用框架: React

复现步骤

1 小程序线上发布成功后, 不能弹出更新提示

代码如下:

import Taro from '@tarojs/taro' import { Component } from 'react'

import './app.scss'

class App extends Component {

componentDidMount() { if (process.env.TARO_ENV === 'weapp') { Taro.cloud.init() } this.doUpdate(); }

componentDidShow() { }

componentDidHide() { }

componentDidCatchError() { }

// this.props.children 是将要会渲染的页面 render() { return this.props.children }

/**

  • 版本更新 */ doUpdate() { if (Taro.canIUse('getUpdateManager')) { const updateManager = Taro.getUpdateManager(); updateManager.onCheckForUpdate(result => { if (result.hasUpdate) { updateManager.onUpdateReady(() => { Taro.showModal({ title: '更新提示', content: '新版本已经准备好,点击重新启动', showCancel: false, success: obj => { if (obj.confirm) { updateManager.applyUpdate(); } }, }); updateManager.onUpdateFailed(() => { Taro.showModal({ title: '提示', content: '检查到有新版本,但是下载失败,请检查网络设置', showCancel: false, }); }); }); } }); } else { Taro.showModal({ title: '提示', content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。' }) } } }

export default App

期望结果

能弹出更新提示

实际结果

没有弹出更新提示

环境信息

👽 Taro v3.0.24


  Taro CLI 3.0.24 environment info:
    System:
      OS: macOS 10.15.5
      Shell: 5.7.1 - /bin/zsh
    Binaries:
      Node: 12.18.3 - ~/.nvm/versions/node/v12.18.3/bin/node
      npm: 6.14.6 - ~/.nvm/versions/node/v12.18.3/bin/npm

shwangson avatar Jan 27 '21 08:01 shwangson

api 都换成 wx. 再试试

Chen-jj avatar Jan 27 '21 11:01 Chen-jj

onUpdateReady 放到外面,不要嵌套调用试试,在我的项目中是可以正常触发的

digiaries avatar Feb 02 '21 09:02 digiaries

onUpdateReady 放到外面,不要嵌套调用试试,在我的项目中是可以正常触发的

您好,您的是嵌套时正常触发还是没有嵌套?

xinian66 avatar Sep 16 '22 10:09 xinian66