我这里用目前最新版本编译到微信小程序时, 是没有问题的.
代码? 配置?
首先, 是否需要?
从调用 Taro.navigateTo、Taro.redirectTo 或 Taro.switchTab 后,到页面触发 componentWillMount 会有一定延时
那如果是函数是否就不会有这样的延迟, 如果会有延迟, componentWillPreload 仍然会有作用.
// 以下方法没有作用, this.$preloadData === null
useEffect(() => {
this.$preloadData.then(res => {
console.log('preloadData', res);
})
}, [])
Component.componentWillPreload = () => Promise.resolve(123)
参考: https://nervjs.github.io/taro/docs/optimized-practice.html