生命周期方法 | 做用 | 说明 |
---|---|---|
componentWillMount | 程序被载入 | 在微信小程序中这一辈子命周期方法对应 app 的 onLaunch |
componentDidMount | 程序被载入 | 在微信小程序中这一辈子命周期方法对应 app 的 onLaunch,在 componentWillMount 后执行 |
componentDidShow | 程序展现出来 | 在微信小程序中这一辈子命周期方法对应 onShow,在 H5 中一样实现 |
componentDidHide | 程序被隐藏 | 在微信小程序中这一辈子命周期方法对应 onHide,在 H5 中一样实现 |
componentDidCatchError | 错误监听函数 | 在微信小程序中这一辈子命周期方法对应 onError |
componentDidNotFound | 页面不存在监听函数 | 在微信小程序中这一辈子命周期方法对应 onPageNotFound |
微信小程序中 onLaunch 一般带有一个参数 options,在 Taro 中你能够在全部生命周期和普通事件方法中经过 this.$router.params 访问到 小程序
生命周期方法 | 做用 | 说明 |
---|---|---|
componentWillMount | 页面被载入 | 在微信小程序中这一辈子命周期方法对应 onLoad |
componentDidMount | 页面渲染完成 | 在微信小程序中这一辈子命周期方法对应 onReady |
shouldComponentUpdate | 页面是否须要更新 | |
componentWillUpdate | 页面即将更新 | |
componentDidUpdate | 页面更新完毕 | |
componentWillUnmount | 页面退出 | 在微信小程序中这一辈子命周期方法对应 onUnload |
componentDidShow | 页面展现出来 | 在微信小程序中这一辈子命周期方法对应 onShow,在 H5 中一样实现 |
componentDidHide | 页面被隐藏 | 在微信小程序中这一辈子命周期方法对应 onHide,在 H5 中一样实现 |
未解决... 因为 navigateBack 的页面会执行 componentDidShow 因此把请求函数写在 componentDidShow 这一周期里 0.0微信小程序