taro在父页面的数据
react + taro
以下是类组件内使用
1、先用json.stringify将其转字符串进行拼接
const value = JSON.stringify(item)
2、通过路由将其传入子页面
onClick={() =>
this.handleClick(
`/pages/my/myball/shop/shopdetail/index?list=${value}`,
)
}
3、子页面在react生命周期内获取到并处理
componentDidMount() {
const list = [JSON.parse(getCurrentInstance().router.params.list)]
this.setState({
showList: list,
})
}
4、跟平常一样拿到传过来的数据就可以使用了