You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
componentWillMount(){console.log("page2 will mount: ")console.log(getCurrentPages().pop().options)}componentDidMount(){console.log("page2 did mount: ")console.log(getCurrentPages().pop().options)}
实际结果
系统信息
Taro v1.2.12
The text was updated successfully, but these errors were encountered:
pamler
changed the title
getCurrentPages 方法在taro的componentWillMount生命周期中调用,获取到的页面对象中没有options这个属性,原生的微信小程序里onLoad中调用该方法是可以获取到的
getCurrentPages 方法在taro的componentWillMount生命周期中调用,获取到的页面对象中没有options这个属性
Feb 11, 2019
问题描述
getCurrentPages 方法在taro的componentWillMount生命周期中调用,获取到的页面对象中没有options这个属性(e.g. 存放了上一个页面带过来的参数等),而在taro的componentDidMount中可以拿的到。但是原生的微信小程序里onLoad中调用该方法的确是可以获取到的,理论上taro的componentWillMount等价于微信小程序的onLoad,所以API的返回结果建议尽量保持一致。
复现步骤
可以拿官方的taro-redux-demo举例,代码如下:
pages/index/index.js中
pages/index2/index.js中
实际结果
系统信息
Taro v1.2.12
The text was updated successfully, but these errors were encountered: