Skip to content

Commit

Permalink
fix(weapp/qq/tt/alipay): 预加载不支持 switchTab,close #5185
Browse files Browse the repository at this point in the history
  • Loading branch information
Chen-jj committed Jan 6, 2020
1 parent 317604c commit 1ce8c48
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/optimized-practice.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ title: 性能优化实践

### 预加载

**微信小程序****支付宝小程序****字节跳动小程序****QQ轻应用**中,从调用 `Taro.navigateTo``Taro.redirectTo``Taro.switchTab` 后,到页面触发 componentWillMount 会有一定延时。因此一些网络请求可以提前到发起跳转前一刻去请求。
**微信小程序****支付宝小程序****QQ轻应用**中,从调用 `Taro.navigateTo``Taro.redirectTo` 后,到页面触发 componentWillMount 会有一定延时。因此一些网络请求可以提前到发起跳转前一刻去请求。

Taro 提供了 `componentWillPreload` 钩子,它接收页面跳转的参数作为参数。可以把需要预加载的内容通过 `return` 返回,然后在页面触发 componentWillMount 后即可通过 `this.$preloadData` 获取到预加载的内容。

Expand Down
2 changes: 1 addition & 1 deletion packages/taro-alipay/src/native-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ function processApis (taro) {
return my[newKey](options)
}

if (key === 'navigateTo' || key === 'redirectTo' || key === 'switchTab') {
if (key === 'navigateTo' || key === 'redirectTo') {
let url = obj['url'] ? obj['url'].replace(/^\//, '') : ''
if (url.indexOf('?') > -1) url = url.split('?')[0]

Expand Down
2 changes: 1 addition & 1 deletion packages/taro-qq/src/native-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function processApis (taro) {
return qq[key](options)
}

if (key === 'navigateTo' || key === 'redirectTo' || key === 'switchTab') {
if (key === 'navigateTo' || key === 'redirectTo') {
let url = obj['url'] ? obj['url'].replace(/^\//, '') : ''
if (url.indexOf('?') > -1) url = url.split('?')[0]

Expand Down
2 changes: 1 addition & 1 deletion packages/taro-tt/src/native-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function processApis (taro) {
return tt[key](options)
}

if (key === 'navigateTo' || key === 'redirectTo' || key === 'switchTab') {
if (key === 'navigateTo' || key === 'redirectTo') {
let url = obj['url'] ? obj['url'].replace(/^\//, '') : ''
if (url.indexOf('?') > -1) url = url.split('?')[0]

Expand Down
2 changes: 1 addition & 1 deletion packages/taro-weapp/src/native-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function processApis (taro) {
return wx[key](options)
}

if (key === 'navigateTo' || key === 'redirectTo' || key === 'switchTab') {
if (key === 'navigateTo' || key === 'redirectTo') {
let url = obj['url'] ? obj['url'].replace(/^\//, '') : ''
if (url.indexOf('?') > -1) url = url.split('?')[0]

Expand Down

0 comments on commit 1ce8c48

Please sign in to comment.