我正在使用react-router与react。我正在尝试在react-router的“链接”中传递属性var React = require('react');var Router = require('react-router');var CreateIdeaView = require('./components/createIdeaView.jsx');var Link = Router.Link;var Route = Router.Route;var DefaultRoute = Router.DefaultRoute;var RouteHandler = Router.RouteHandler;var App = React.createClass({ render : function(){ return( <div> <Link to="ideas" params={{ testvalue: "hello" }}>Create Idea</Link> <RouteHandler/> </div> ); }});var routes = ( <Route name="app" path="/" handler={App}> <Route name="ideas" handler={CreateIdeaView} /> <DefaultRoute handler={Home} /> </Route>);Router.run(routes, function(Handler) { React.render(<Handler />, document.getElementById('main'))});“链接”呈现页面,但不将属性传递给新视图。下面是查看代码var React = require('react');var Router = require('react-router');var CreateIdeaView = React.createClass({ render : function(){ console.log('props form link',this.props,this)//props not recived return( <div> <h1>Create Post: </h1> <input type='text' ref='newIdeaTitle' placeholder='title'></input> <input type='text' ref='newIdeaBody' placeholder='body'></input> </div> ); }});module.exports = CreateIdeaView;如何使用“链接”传递数据?
添加回答
举报
0/150
提交
取消