zoukankan      html  css  js  c++  java
  • react-router跳转传值

    跳转页面传递参数

    1.引入包 
    import {hashHistory} from ‘React-router’

    2.跳转传值

        handleClick = (value) => {
            hashHistory.push({
                pathname: 'message/detailMessage',
                query: {
                    title:value.title,
                    time:value.time,
                    text:value.text
                },
            })
        }

    3.接收值

    console.info(this.props.location.query.title)
    console.info(this.props.location.query.time)
    console.info(this.props.location.query.text)

     4.如果使用的ant design,可以在model里面获取结果,当然也可以在组件里面获取结果

    组件页面获取结果的写法为:

    import {hashHistory} from 'react-router';
    
    hashHistory.listen(location => {
              //获取传递的数据,对象、值....    
                console.log(location.query);
              // 获取路径
            console.log(location.pathname);
        }
    })
  • 相关阅读:
    spring的常用配置
    aop切入点表达式
    代理模式
    hibernate的常用配置
    正则表达式
    Java配置
    性能提升
    创建vue3 项目
    manjaro
    单调队列
  • 原文地址:https://www.cnblogs.com/mabylove/p/7078987.html
Copyright © 2011-2022 走看看