taro icon indicating copy to clipboard operation
taro copied to clipboard

部署项目,跳转失败,navigateTo:fail e.push is not a function

Open peng92055 opened this issue 7 years ago • 3 comments

问题描述

使用Taro打包H5项目,部署到web上访问正常,但是调用Taro.navigateTo等跳转类报错 注: 本地开发环境跳转正常,打build部署跳转就失败了 报错截图如下 image image

看源码是createNavigateTo(e) 传递的参数不是开发环境时的history,而是index.js中 h5配置的router,自然就缺少了push方法,求作者看看是否配置文件出错

复现步骤

  1. 配置项目
  2. 部署项目 跑npm run build:h5
  3. 任意页面使用Taro.navigationTo失败

index.js中h5配置如下 h5: { publicPath: '/mini', staticDirectory: 'static', router: { mode: 'browser', basename: '/mini', customRoutes: { '/pages/guards/index': '/guards', } }, output: { filename: 'js/[name].[hash:8].js', chunkFilename: 'js/[name].[chunkhash:8].js' }, imageUrlLoaderOption: { limit: 5000, name: 'static/images/[name].[hash:8].[ext]' }, miniCssExtractPluginOption: { filename: 'css/[name].[hash:8].css', chunkFilename: 'css/[name].[chunkhash:8].css', }, esnextModules: ['taro-ui'], module: { postcss: { autoprefixer: { enable: true, config: { browsers: [ 'last 3 versions', 'Android >= 4.1', 'ios >= 8' ] } }, cssModules: { enable: false, config: { namingPattern: 'module', generateScopedName: '[name][local]_[hash:base64:5]' } } } } }


**期望行为**
解决跳转问题

**报错信息**
 Uncaught (in promise) {errMsg: "navigateTo:fail e.push is not a function"}

**系统信息**
Taro CLI 1.3.13 environment info:
    System:
      OS: macOS 10.14.6
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 11.15.0 - /usr/local/bin/node
      Yarn: 1.17.3 - ~/.yarn/bin/yarn
      npm: 6.7.0 - /usr/local/bin/npm
    npmPackages:
      @tarojs/async-await: 1.3.13 => 1.3.13 
      @tarojs/components: 1.3.13 => 1.3.13 
      @tarojs/plugin-babel: 1.3.13 => 1.3.13 
      @tarojs/plugin-csso: 1.3.13 => 1.3.13 
      @tarojs/plugin-sass: 1.3.13 => 1.3.13 
      @tarojs/plugin-uglifyjs: 1.3.13 => 1.3.13 
      @tarojs/redux: 1.3.13 => 1.3.13 
      @tarojs/redux-h5: 1.3.13 => 1.3.13 
      @tarojs/router: 1.3.13 => 1.3.13 
      @tarojs/taro: 1.3.13 => 1.3.13 
      @tarojs/taro-alipay: 1.3.13 => 1.3.13 
      @tarojs/taro-h5: 1.3.13 => 1.3.13 
      @tarojs/taro-swan: 1.3.13 => 1.3.13 
      @tarojs/taro-tt: 1.3.13 => 1.3.13 
      @tarojs/taro-weapp: 1.3.13 => 1.3.13 
      @tarojs/webpack-runner: 1.3.13 => 1.3.13 
      eslint-config-taro: 1.3.13 => 1.3.13 
      eslint-plugin-taro: 1.3.13 => 1.3.13 
      nerv-devtools: ^1.4.0 => 1.4.4 
      nervjs: ^1.4.0 => 1.4.4 
      stylelint-config-taro-rn: 1.3.13 => 1.3.13 
      stylelint-taro-rn: 1.3.13 => 1.3.13 
    npmGlobalPackages:
      typescript: 2.7.2

 - 报错平台 [h5]

peng92055 avatar Sep 12 '19 09:09 peng92055

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

taro-bot[bot] avatar Sep 12 '19 09:09 taro-bot[bot]

CC @Littly

taro-bot[bot] avatar Sep 16 '19 02:09 taro-bot[bot]

taro版本与项目taro版本不一致

chenkefeng avatar Sep 19 '19 07:09 chenkefeng