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

React-Router v4 #7

Closed
wuyuanlijie opened this issue Mar 12, 2018 · 0 comments
Closed

React-Router v4 #7

wuyuanlijie opened this issue Mar 12, 2018 · 0 comments

Comments

@wuyuanlijie
Copy link
Owner

wuyuanlijie commented Mar 12, 2018

这里使用的react-router-dom这个API 理念:万物皆是组件 react-router-dom用于DOM绑定的React Router

Provider是用来保持与store的更新,Router是用来保持与loaction的同步 (Router的角色类似与Provider)

Router组件下只允许存在一个子元素,可以包裹一个div,或者只使用一个Route

Route组件主要的作用的就是当一个location匹配一个路由的path,渲染某些UI,

  • 组件有以下的属性:path路由的匹配路径; exact为true的时候,则要求路径必须与location.pathname完全的匹配。
  • strict为true的时候,有结尾的斜线的路径只能匹配有斜线的loaction.pathname (包括斜线后面的部分)

Route中的三种渲染的方法:

  1. component,在地址匹配的时候React组件才会被渲染,route props也会随着一起被渲染 (优先级高于render)
  2. render 这种对于内联渲染和包装的组件却不会引起意料之外的重现挂载 (包装组件,例如调用重定向,参数是一个函数,返回一个数组)
  3. children 和render的工作方式基本相同,除了它是不管地址匹配与否会被调用。
  • 、:是的特定的版本,会在匹配上的当前url时候给已经渲染的元素添加样式参数。
  • 该组建用来渲染匹配地址的第一个或者,独特之处它仅仅渲染一个路由!!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant