Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jswxwxf opened this issue Dec 18, 2018 · 8 comments
Closed

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

jswxwxf opened this issue Dec 18, 2018 · 8 comments
Assignees

Comments

@jswxwxf
Copy link

jswxwxf commented Dec 18, 2018

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

@taro-bot
Copy link

taro-bot bot commented Dec 18, 2018

欢迎提交 Issue~

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

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

Good luck and happy coding~

@luckyadam
Copy link
Member

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

@jswxwxf
Copy link
Author

jswxwxf commented Dec 18, 2018

这是我的 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"
  }
}

@tourze
Copy link
Contributor

tourze commented Jan 1, 2019

+1

@luckyadam
Copy link
Member

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

@AvailCat
Copy link

AvailCat commented Jan 21, 2019

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

if (buildAdapter === Util.BUILD_TYPES.WEAPP) {
node.body.push(template(`Component(require('${taroMiniAppFrameworkPath}').default.createComponent(${exportVariableName}, true))`, babylonConfig)())
} else {
node.body.push(template(`Page(require('${taroMiniAppFrameworkPath}').default.createComponent(${exportVariableName}, true))`, babylonConfig)())
}

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

@luckyadam
Copy link
Member

@Meeeeow 大赞~

@Chen-jj
Copy link
Contributor

Chen-jj commented Apr 10, 2019

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

image

@Chen-jj Chen-jj closed this as completed Apr 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants