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

子组件不能执行onShow里面的内容 #179

Closed
noahlam opened this issue Mar 26, 2018 · 3 comments
Closed

子组件不能执行onShow里面的内容 #179

noahlam opened this issue Mar 26, 2018 · 3 comments

Comments

@noahlam
Copy link

noahlam commented Mar 26, 2018

[问题简单描述]

问题复现步骤:

  1. 在子组件不会执行onShow里面的内容
  2. onLoad () {
    console.log('onLoad')
    },
    onShow () {
    console.log('onShow')
    },
    mounted () {
    console.log('mounted')
    },

期望的表现:

应该要打印
onLoad
onShow
mounted

观察到的表现:

打印结果
onLoad
mounted

@noahlam
Copy link
Author

noahlam commented Mar 26, 2018

进一步排查了一下,发现子组件的onShow生命周期,只有在页面第二次显示的时候,才会执行,而父组件的onShow,每次页面显示都会执行,包括第一次

@rchunping
Copy link

作为Page的才有这些生命周期函数吧

@aOrz
Copy link
Member

aOrz commented Apr 4, 2018

因为在 onShow 的时候,子组件还没有创建,所以子组件第一次不会有 onShow 触发

@aOrz aOrz closed this as completed Apr 23, 2018
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

3 participants