Commit 9161afbf by Wee

docs(README): update README

parent da56e71b
...@@ -53,9 +53,11 @@ There is a item list page, click on the items on this page will enter the item d ...@@ -53,9 +53,11 @@ There is a item list page, click on the items on this page will enter the item d
## Usage ## Usage
### livePath ### livePath: string or array
`livePath` is the path you want to hide the component instead of unmount it. The specific rules of `livePath` are the same as `path` props of Route in react-router-v4. You still can use `component` or `render` props to render a component. `livePath` is the path you want to hide the component instead of unmount it. The specific rules of `livePath` are the same as `path` props of Route in react-router-v4. You still can use `component` or `render` props to render a component.
`livePath` also can accept an array of string above since 1.2.0. `livePath` is matched if any string in the array is matched.
LiveRoute will re-render when it come back from a `path` matching location from the `livePath` matching location. It will unmount on other unmatched locations. LiveRoute will re-render when it come back from a `path` matching location from the `livePath` matching location. It will unmount on other unmatched locations.
...@@ -69,7 +71,7 @@ import LiveRoute from 'react-live-route' ...@@ -69,7 +71,7 @@ import LiveRoute from 'react-live-route'
<LiveRoute path="/list" livePath="/user/:id" component={List} /> <LiveRoute path="/list" livePath="/user/:id" component={List} />
``` ```
### alwaysLive ### alwaysLive: bool
`alwaysLive` is just like `livePath`. The difference is the component will not be unmount on **any other location** after the it's first mount. `alwaysLive` is just like `livePath`. The difference is the component will not be unmount on **any other location** after the it's first mount.
......
...@@ -57,6 +57,8 @@ yarn add react-live-route --dev. ...@@ -57,6 +57,8 @@ yarn add react-live-route --dev.
`livePath` 为需要隐藏的页面的路径,具体规则与 react-router 中的 Route 的 `path` props 一样,使用 `component``render` 来渲染路由对应的组件。 `livePath` 为需要隐藏的页面的路径,具体规则与 react-router 中的 Route 的 `path` props 一样,使用 `component``render` 来渲染路由对应的组件。
`livePath` 也可以接受一个由上述规则的 string 类型对象组成的数组,如果数组中的任意一个 string 匹配则 `livePath` 匹配。
LiveRoute 会在从 `livePaht` 匹配的路径返回 `path` 匹配的路径时冲渲染,在进入其他不匹配的路径时会直接卸载。 LiveRoute 会在从 `livePaht` 匹配的路径返回 `path` 匹配的路径时冲渲染,在进入其他不匹配的路径时会直接卸载。
例如: 例如:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment