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

h5环境下useRouter无法获取params #7871

Closed
shuwenjunn opened this issue Oct 20, 2020 · 1 comment · Fixed by #7873
Closed

h5环境下useRouter无法获取params #7871

shuwenjunn opened this issue Oct 20, 2020 · 1 comment · Fixed by #7873
Labels
F-react Framework - React T-h5 Target - 编译到 H5 V-3 Version - 3.x
Milestone

Comments

@shuwenjunn
Copy link

shuwenjunn commented Oct 20, 2020

相关平台

H5

浏览器版本: 版本 85.0.4183.121(正式版本) (64 位)
使用框架: React

复现步骤

首页跳转到我的页面

首页代码

import React from "react";
import { View } from "@tarojs/components";
import Taro from "@tarojs/taro";

export default function Index() {
  const goMine = () => {
    Taro.navigateTo({
      url: "/pages/mine/index?id=1"
    });
  };
  return <View onClick={goMine}>跳转至我的页面</View>;
}

我的页面 代码

import React from "react";
import { View } from "@tarojs/components";
import Taro, { useRouter } from "@tarojs/taro";

export default function Index() {
  const router = useRouter();
  console.log("router--------->>", router.params);
  return <View>我是MINE</View>;
}

期望结果

console.log("router--------->>", router.params);输出结果应为{id:1}

实际结果

console.log("router--------->>", router.params);输出结果为 {}

环境信息

 Taro v3.0.14


  Taro CLI 3.0.14 environment info:
    System:
      OS: macOS 10.15.6
      Shell: 5.7.1 - /bin/zsh
    Binaries:
      Node: 12.16.3 - /usr/local/bin/node
      Yarn: 1.22.4 - /usr/local/bin/yarn
      npm: 6.14.7 - /usr/local/bin/npm
    npmPackages:
      @tarojs/cli: 3.0.14 => 3.0.14
      @tarojs/components: 3.0.14 => 3.0.14
      @tarojs/mini-runner: 3.0.14 => 3.0.14
      @tarojs/react: 3.0.14 => 3.0.14
      @tarojs/runtime: 3.0.14 => 3.0.14
      @tarojs/taro: 3.0.14 => 3.0.14
      @tarojs/webpack-runner: 3.0.14 => 3.0.14
      babel-preset-taro: 3.0.14 => 3.0.14
      eslint-config-taro: 3.0.14 => 3.0.14
      react: ^16.10.0 => 16.14.0
      taro-ui: ^3.0.0-alpha.3 => 3.0.0-alpha.3
    npmGlobalPackages:
      typescript: 3.9.7
@taro-bot2 taro-bot2 bot added F-react Framework - React T-h5 Target - 编译到 H5 V-3 Version - 3.x labels Oct 20, 2020
@luckyadam luckyadam added this to the 3.0.15 milestone Oct 20, 2020
@ghostogre
Copy link

我是直接使用H5的获取url,然后自己截取处理

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-3 Version - 3.x
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants