提交 5ab71d16 编写于 作者: G Guillermo Rauch 提交者: GitHub

Update README.md

上级 c890dc35
......@@ -282,21 +282,13 @@ If you are no longer want to listen to that event, you can simply unset the even
Router.onRouteChangeStart = null
```
##### Cancelled (Abort) Routes
Sometimes, you might want to change a route before the current route gets completed. Current route may be downloading the page or running `getInitialProps`.
In that case, we abort the current route and process with the new route.
If you need, you could capture those cancelled routes via `routeChangeError` router event. See:
If a route load is cancelled (for example by clicking two links rapidly in succession), `routeChangeError` will fire. The passed `err` will contained a `cancelled` property set to `true`.
```js
Router.onRouteChangeError = (err, url) => {
if (err.cancelled) {
console.log(`Route to ${url} is cancelled!`)
return
console.log(`Route to ${url} was cancelled!`)
}
// Some other error
}
```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册