From 561b13c8a4c873a0bea34ab3c612486432d9116c Mon Sep 17 00:00:00 2001 From: Miguel Espinoza Date: Thu, 8 Nov 2018 00:47:49 +0100 Subject: [PATCH] Add example for m.route.set with params (#2229) Add example on how to use m.route.set with params --- docs/route.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/route.md b/docs/route.md index 630ca16b..c48f0e56 100644 --- a/docs/route.md +++ b/docs/route.md @@ -78,6 +78,19 @@ Argument | Type | Required | Description `options.title` | `String` | No | The `title` string to pass to the underlying `history.pushState` / `history.replaceState` call. **returns** | | | Returns `undefined` +Remember that when using `.set` with params you also need to define the route: +```javascript +var Article = { + view: function(vnode) { + return "This is article " + vnode.attrs.articleid + } +} + +m.route(document.body, { + '/article/:articleid': Article +}) +m.route.set('/article/:articleid', {articleid: 1}) +``` ##### m.route.get Returns the last fully resolved routing path, without the prefix. It may differ from the path displayed in the location bar while an asynchronous route is [pending resolution](#code-splitting).