首页 > 其他 > 详细

[React] React Router: Querystring Parameters

时间:2016-03-30 14:53:25      阅读:333      评论:0      收藏:0      [点我收藏+]

Define query param in Link, accept path and query :

const Links = () =>
    <nav >
        <Link to={{path: ‘/‘, query: {message: ‘Yo‘}}}>Home</Link>
    </nav>;

 

Use Query param by props.location.query:

const Container = (props) => <div>{props.location.query.message || ‘Hello‘}<Links /></div>;

 

-----------------------

import React from ‘react‘;
import {hashHistory, Route, Router, Link, IndexRoute} from ‘react-router‘;

const Container = (props) => <div>{props.location.query.message || ‘Hello‘}<Links /></div>;

const Links = () =>
    <nav >
        <Link to={{path: ‘/‘, query: {message: ‘Yo‘}}}>Home</Link>
    </nav>;

class App extends React.Component {
    render(){
        return(
            <Router history={hashHistory}>
                <Route path="/" component={Container}></Route>
            </Router>
        );
    }
}

export default App;

 

[React] React Router: Querystring Parameters

原文:http://www.cnblogs.com/Answer1215/p/5336857.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!