Taro: 请问要怎么样才能使组件的 componentDidShow 起作用啊?

Created on 18 Dec 2018  ·  8Comments  ·  Source: NervJS/taro

原来以为 1.2.0 里可以,但是发现还是不行。只有页面的 componentDidShow 可以工作。

Most helpful comment

@luckyadam @jswxwxf @tourze 在微信官方社区看到 组件嵌套时pageLifetimes中的show不会被触发 的反馈,Taro 的页面也是用了 Component 构造器 而不是 Page 构造器,似乎是会触发这个问题的

https://github.com/NervJS/taro/blob/cfb49092fa0bde2b62f97c3ffe845e262d571936/packages/taro-cli/src/weapp.js#L765-L769

BTW: 询问了微信的朋友说这个 Bug 已经安排处理了

All 8 comments

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

项目依赖也升级到最新版本了么

这是我的 package.json

{
  "name": "mina",
  "version": "1.0.0",
  "private": true,
  "description": "...",
  "scripts": {
    "build:weapp": "taro build --type weapp",
    "build:swan": "taro build --type swan",
    "build:alipay": "taro build --type alipay",
    "build:h5": "taro build --type h5",
    "build:rn": "taro build --type rn",
    "dev:weapp": "npm run build:weapp -- --watch",
    "dev:swan": "npm run build:swan -- --watch",
    "dev:alipay": "npm run build:alipay -- --watch",
    "dev:h5": "npm run build:h5 -- --watch",
    "dev:rn": "npm run build:rn -- --watch"
  },
  "author": "",
  "license": "MIT",
  "dependencies": {
    "@tarojs/async-await": "^1.2.0",
    "@tarojs/components": "^1.2.0",
    "@tarojs/redux": "^1.2.0",
    "@tarojs/redux-h5": "^1.2.0",
    "@tarojs/router": "^1.2.0",
    "@tarojs/taro": "^1.2.0",
    "@tarojs/taro-alipay": "^1.2.0",
    "@tarojs/taro-h5": "^1.2.0",
    "@tarojs/taro-swan": "^1.2.0",
    "@tarojs/taro-weapp": "^1.2.0",
    "axios": "^0.18.0",
    "classnames": "^2.2.6",
    "dva-core": "^1.4.0",
    "dva-loading": "^2.0.5",
    "lodash": "^4.17.11",
    "moment": "^2.23.0",
    "nervjs": "^1.3.9",
    "react-redux": "^6.0.0",
    "redux": "^4.0.0",
    "redux-logger": "^3.0.6",
    "redux-thunk": "^2.3.0",
    "taro-ui": "^1.5.1",
    "validatorjs": "^3.15.1"
  },
  "devDependencies": {
    "@types/react": "^16.7.17",
    "@types/webpack-env": "^1.13.6",
    "@tarojs/plugin-babel": "^1.2.0",
    "@tarojs/plugin-csso": "^1.2.0",
    "@tarojs/plugin-sass": "^1.2.0",
    "@tarojs/plugin-uglifyjs": "^1.2.0",
    "@tarojs/webpack-runner": "^1.2.0",
    "babel-plugin-transform-class-properties": "^6.24.1",
    "babel-plugin-transform-decorators-legacy": "^1.3.4",
    "babel-plugin-transform-jsx-stylesheet": "^0.6.5",
    "babel-plugin-transform-object-rest-spread": "^6.26.0",
    "babel-preset-env": "^1.6.1",
    "babel-eslint": "^8.2.3",
    "eslint": "^4.19.1",
    "eslint-config-taro": "^1.2.0",
    "eslint-plugin-react": "^7.8.2",
    "eslint-plugin-import": "^2.12.0",
    "eslint-plugin-taro": "^1.2.0"
  }
}

+1

暂时将状态从页面传下去吧

@luckyadam @jswxwxf @tourze 在微信官方社区看到 组件嵌套时pageLifetimes中的show不会被触发 的反馈,Taro 的页面也是用了 Component 构造器 而不是 Page 构造器,似乎是会触发这个问题的

https://github.com/NervJS/taro/blob/cfb49092fa0bde2b62f97c3ffe845e262d571936/packages/taro-cli/src/weapp.js#L765-L769

BTW: 询问了微信的朋友说这个 Bug 已经安排处理了

@Meeeeow 大赞~

@jswxwxf CLI 、依赖、开发者工具都升级到最新版本后应该能正常触发了。

image

Was this page helpful?
0 / 5 - 0 ratings