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

navigateTo is not a function #9496

Closed
leexm0101 opened this issue Jun 10, 2021 · 2 comments
Closed

navigateTo is not a function #9496

leexm0101 opened this issue Jun 10, 2021 · 2 comments
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x

Comments

@leexm0101
Copy link

相关平台

微信小程序

小程序基础库: 2.17.0
使用框架: React

复现步骤

// @ts-ignore
const Home: React.FC = (props: IProps) => {
return
<AtButton type="primary" onClick={() => {
console.log('Taro', Taro)
console.log('Taro.navigateTo', Taro.navigateTo)

  Taro.navigateTo({
    url: 'index',
  })
}}>navigateTo</AtButton>
}

使用Taro.navigateTo跳转到应用内的某个页面,报navigateTo is not a function

import { navigateTo } from '@tarojs/router' 方式引用,报window undefined

期望结果

http://taro-docs.jd.com/taro/docs/apis/route/navigateTo
按照文档正常跳转

实际结果

如描述,报错

环境信息

  Taro CLI 3.2.8 environment info:
    System:
      OS: macOS 11.4
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 14.17.0 - ~/.nvm/versions/node/v14.17.0/bin/node
      Yarn: 1.22.10 - /usr/local/bin/yarn
      npm: 6.14.13 - ~/.nvm/versions/node/v14.17.0/bin/npm
    npmPackages:
      @tarojs/cli: 3.2.10 => 3.2.10 
      @tarojs/components: 3.2.10 => 3.2.10 
      @tarojs/mini-runner: 3.2.10 => 3.2.10 
      @tarojs/react: 3.2.10 => 3.2.10 
      @tarojs/runtime: 3.2.10 => 3.2.10 
      @tarojs/taro: 3.2.10 => 3.2.10 
      @tarojs/webpack-runner: 3.2.10 => 3.2.10 
      babel-preset-taro: 3.2.10 => 3.2.10 
      eslint-config-taro: 3.2.10 => 3.2.10 
      react: ^17.0.0 => 17.0.2 
      taro-ui: ^3.0.0-alpha => 3.0.0-alpha.10 
@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Jun 10, 2021
@leexm0101
Copy link
Author

import { navigateTo } from '@tarojs/router' 方式引用,报window.addEventListener is not a function

@Chen-jj
Copy link
Contributor

Chen-jj commented Jun 10, 2021

Taro CLI 和 Taro 依赖版本保持一致。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Projects
None yet
Development

No branches or pull requests

2 participants