NervJS / taro

开放式跨端跨框架解决方案,支持使用 React/Vue/Nerv 等框架来开发微信/京东/百度/支付宝/字节跳动/ QQ 小程序/H5/React Native 等应用。 https://taro.zone/
https://docs.taro.zone/
Other
35.46k stars 4.78k forks source link

pagelifetimes 无法生效 #9570

Open wuazhu opened 3 years ago

wuazhu commented 3 years ago

相关平台

微信小程序

复现仓库

https://git.jd.com/MP_FE/speedjd 小程序基础库: 2.17.3 使用框架: React

复现步骤

项目是微信源码使用 taro convert 转换成了 taro3 的 react, 在微信组件里有 pageLifetimes 里面有 show 生命周期, 但是转换后的代码不执行这个生命周期

代码如下

@withWeapp({
  pageLifetimes: {
    show() {
     // 这里无法进入
      this.changeAddress()
    }
  },
  methods: {
    changeAddress() {
        console.log('change address')
    }
  }
})
class _C extends Component {
...
}

期望结果

执行生命周期

实际结果

不执行 pageLifetimes 里的生命周期

环境信息

Taro v3.2.10
Taro CLI 3.2.10 environment info:
    System:
      OS: macOS 10.15.6
      Shell: 5.7.1 - /bin/zsh
    Binaries:
      Node: 12.20.1 - ~/.nvm/versions/node/v12.20.1/bin/node
      npm: 6.14.10 - ~/.nvm/versions/node/v12.20.1/bin/npm
    npmPackages:
      @tarojs/cli: 3.2.10 => 3.2.10
      @tarojs/components: 3.2.10 => 3.2.10
      @tarojs/helper: 3.2.10 => 3.2.10
      @tarojs/mini-runner: ^3.2.10 => 3.2.10
      @tarojs/plugin-platform-alipay: ^3.2.10 => 3.2.10
      @tarojs/plugin-platform-jd: ^3.2.10 => 3.2.10
      @tarojs/plugin-platform-qq: ^3.2.10 => 3.2.10
      @tarojs/plugin-platform-swan: ^3.2.10 => 3.2.10
      @tarojs/plugin-platform-tt: ^3.2.10 => 3.2.10
      @tarojs/plugin-platform-weapp: ^3.2.10 => 3.2.10
      @tarojs/react: 3.2.10 => 3.2.10
      @tarojs/router: 3.2.10 => 3.2.10
      @tarojs/runner-utils: 3.2.10 => 3.2.10
      @tarojs/service: 3.2.10 => 3.2.10
      @tarojs/shared: 3.2.10 => 3.2.10
      @tarojs/taro: 3.2.10 => 3.2.10
      @tarojs/taro-h5: 3.2.10 => 3.2.10
      @tarojs/taro-loader: 3.2.10 => 3.2.10
      @tarojs/taroize: 3.2.10 => 3.2.10
      @tarojs/webpack-runner: 3.2.10 => 3.2.10
      @tarojs/with-weapp: ^3.2.10 => 3.2.10
      babel-preset-taro: ^3.2.10 => 3.2.12
      eslint-config-taro: 3.2.10 => 3.2.10
      eslint-plugin-taro: 3.2.10 => 3.2.10
      react: ^17.0.2 => 17.0.2
    npmGlobalPackages:
      typescript: 4.2.3
zjxpcyc commented 3 years ago

坐等官方解决