Skip to content
New issue

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

调用Taro.redirectTo不能正常跳转 #8241

Closed
shenX-2021 opened this issue Dec 10, 2020 · 0 comments
Closed

调用Taro.redirectTo不能正常跳转 #8241

shenX-2021 opened this issue Dec 10, 2020 · 0 comments
Labels
F-react Framework - React T-h5 Target - 编译到 H5 V-2 Version - 2.x

Comments

@shenX-2021
Copy link

相关平台

H5

复现仓库

https://github.com/gxsandzxl/taro-bug-demo2
浏览器版本: 浏览器版本: Chrome 版本 87.0.4280.88(正式版本) (64 位)
使用框架: React

复现步骤

app.jsxcomponentDidMount钩子里异步调用Taro.redirectTo方法会报错,同步调用则不会

// app.jsx
class App extends Component {
    componentDidMount () {
        console.log('app mount')
        setTimeout(() => {
          Taro.redirectTo({url: '/pages/index/index'});
        });
    }
}

报错栈:

index.esm.js?eb04:2680 showPage:fail Received a falsy component for route "/pages/index/index". Forget to export it?
index.esm.js?eb04:2657 Uncaught (in promise) TypeError: Cannot read property 'componentDidShow' of undefined
    at Route.componentWillReceiveProps (index.esm.js?eb04:2657)
    at eval (index.esm.js?eb37:1900)
    at errorCatcher (index.esm.js?eb37:1749)
    at reRenderComponent (index.esm.js?eb37:1899)
    at ComponentWrapper.update (index.esm.js?eb37:2263)
    at patch (index.esm.js?eb37:993)
    at patchKeyedChildren (index.esm.js?eb37:1122)
    at patchArrayChildren (index.esm.js?eb37:1050)
    at patchChildren (index.esm.js?eb37:1064)
    at patch (index.esm.js?eb37:987)

期望结果

在异步回调里能成功调用Taro.redirectTo方法

实际结果

报错:

index.esm.js?eb04:2680 showPage:fail Received a falsy component for route "/pages/index/index". Forget to export it?

环境信息

Taro CLI 2.2.14 environment info:
    System:
      OS: Windows 10
    Binaries:
      Node: 12.16.3 - D:\Program Files\nodejs\node.EXE
      Yarn: 1.22.4 - D:\Program Files\Yarn\bin\yarn.CMD
      npm: 6.14.4 - D:\Program Files\nodejs\npm.CMD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-h5 Target - 编译到 H5 V-2 Version - 2.x
Projects
Archived in project
Development

No branches or pull requests

2 participants