We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
问题描述 componentWillMount 中获取不到this.$preloadData 打印出来是undefined
复现步骤 [复现问题的步骤] 例如:A页面跳转至B页面
export default class A extends Component { config = { navigationBarTitleText: '首页' } click(param) { Taro.navigateTo({ url: '/pages/preload/preload?url=hello' }) } render () { return ( <View className='index'> <Text>Hello world!</Text> <View onClick={this.click}> <Text>点击跳转</Text> </View> </View> ) } }
export default class B extends Component { constructor() { super(...arguments); } config = { navigationBarTitleText: '预加载页面' }; componentWillMount () { console.log('isFetching: ', this.isFetching) this.$preloadData .then(res => { console.log('res: ', res) this.isFetching = false }) } componentWillPreload (params) { return this.fetchData(params.url) } fetchData () { this.isFetching = true; } render() { return ( <View className='container'> <Text>B页面</Text> </View> ); } }
期望行为 正常使用this.$preloadData获取到值
报错信息
[这里请贴上你的完整报错截图或文字]
系统信息
操作系统: win10
Taro 版本
Node.js 版本
报错平台 weapp
补充信息
The text was updated successfully, but these errors were encountered:
欢迎提交 Issue~
如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏
如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。
Good luck and happy coding~
Sorry, something went wrong.
CC @Chen-jj
目测是由于 fetchData 没有返回数据,这个例子不是很完整,你可以在 fetchData 里返回一个 promise 试试
fetchData
那建议可以修改一下文档的例子,我还以为返回的数据是taro自动封装到promise里面的呢
Chen-jj
No branches or pull requests
问题描述
componentWillMount 中获取不到this.$preloadData
打印出来是undefined
复现步骤
[复现问题的步骤]
例如:A页面跳转至B页面
期望行为
正常使用this.$preloadData获取到值
报错信息
[这里请贴上你的完整报错截图或文字]
系统信息
操作系统: win10
Taro 版本
Node.js 版本
报错平台
weapp
补充信息
The text was updated successfully, but these errors were encountered: