We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
React-router是基于history库来创建的。简单来讲,history可以知道如何监听浏览器地址栏的改变从而将URL解析到location对象中,这样的话,router就可以匹配到每一条routes并且正确的渲染一系列的组件。
component的传入值只能为具体的组件 components的传入值可以为对象或具体的组件
render(){ console.log(this.props); return (.....); }
在每一条Route对应渲染的组件中都可以拿到this.context.route,这个对象上面挂载了很多API,setRouteLeaveHook这个是常用的。
接口约束,如果这个组件写了调用路由相关的API进行操作,但是本身没有放在router下面进行渲染,会给出友好的提示。
The text was updated successfully, but these errors were encountered:
👍
Sorry, something went wrong.
No branches or pull requests
React-router教程的内容补充
1.hashHistory和browserHistory的区别
React-router是基于history库来创建的。简单来讲,history可以知道如何监听浏览器地址栏的改变从而将URL解析到location对象中,这样的话,router就可以匹配到每一条routes并且正确的渲染一系列的组件。
2.每一条Route中参数component和components有什么不一样
component的传入值只能为具体的组件
components的传入值可以为对象或具体的组件
3.尽量使用activeClassName来改变被触发的Link的展示样式
4.组件中是如何拿到路由相关的信息的
5.this.context.route是从哪里来的
在每一条Route对应渲染的组件中都可以拿到this.context.route,这个对象上面挂载了很多API,setRouteLeaveHook这个是常用的。
6.为什么要设置组件的contextType
接口约束,如果这个组件写了调用路由相关的API进行操作,但是本身没有放在router下面进行渲染,会给出友好的提示。
The text was updated successfully, but these errors were encountered: