Feature onmatch route param (#2371)
* added route param in onmatch * fix docs * included test * docs fix
This commit is contained in:
parent
6f8f011b88
commit
a9172f1129
3 changed files with 15 additions and 9 deletions
|
|
@ -176,12 +176,13 @@ This method also allows you to asynchronously define what component will be rend
|
|||
|
||||
For more information on `onmatch`, see the [advanced component resolution](#advanced-component-resolution) section
|
||||
|
||||
`routeResolver.onmatch(args, requestedPath)`
|
||||
`routeResolver.onmatch(args, requestedPath, route)`
|
||||
|
||||
Argument | Type | Description
|
||||
--------------- | ---------------------------------------- | ---
|
||||
`args` | `Object` | The [routing parameters](#routing-parameters)
|
||||
`requestedPath` | `String` | The router path requested by the last routing action, including interpolated routing parameter values, but without the prefix. When `onmatch` is called, the resolution for this path is not complete and `m.route.get()` still returns the previous path.
|
||||
`route` | `String` | The router path requested by the last routing action, excluding interpolated routing parameter values
|
||||
**returns** | `Component|Promise<Component>|undefined` | Returns a component or a promise that resolves to a component
|
||||
|
||||
If `onmatch` returns a component or a promise that resolves to a component, this component is used as the `vnode.tag` for the first argument in the RouteResolver's `render` method. Otherwise, `vnode.tag` is set to `"div"`. Similarly, if the `onmatch` method is omitted, `vnode.tag` is also `"div"`.
|
||||
|
|
@ -429,7 +430,7 @@ Instead of mapping a component to a route, you can specify a RouteResolver objec
|
|||
```javascript
|
||||
m.route(document.body, "/", {
|
||||
"/": {
|
||||
onmatch: function(args, requestedPath) {
|
||||
onmatch: function(args, requestedPath, route) {
|
||||
return Home
|
||||
},
|
||||
render: function(vnode) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue