Merge remote-tracking branch 'origin/rewrite' into rewrite
This commit is contained in:
commit
41c7a61960
1 changed files with 57 additions and 0 deletions
|
|
@ -9,6 +9,8 @@ Migrating from `v0.2.x` to `v1.x`
|
||||||
- [Component arguments](#component-arguments)
|
- [Component arguments](#component-arguments)
|
||||||
- [Passing components to `m()`](#passing-components-to-m)
|
- [Passing components to `m()`](#passing-components-to-m)
|
||||||
- [`m.route` and anchor tags](#mroute-and-anchor-tags)
|
- [`m.route` and anchor tags](#mroute-and-anchor-tags)
|
||||||
|
- [Reading/writing the current route](#readingwriting-the-current-route)
|
||||||
|
- [Accessing route params](#accessing-route-params)
|
||||||
|
|
||||||
## `config` function
|
## `config` function
|
||||||
|
|
||||||
|
|
@ -197,3 +199,58 @@ m("a", {
|
||||||
oncreate : m.route.link
|
oncreate : m.route.link
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Reading/writing the current route
|
||||||
|
|
||||||
|
In `v0.2.x` all interaction w/ the current route happened via `m.route()`. In `v1.x` this has been broken out into two functions.
|
||||||
|
|
||||||
|
### `v0.2.x`
|
||||||
|
|
||||||
|
```js
|
||||||
|
// Getting the current route
|
||||||
|
m.route()
|
||||||
|
|
||||||
|
// Setting a new route
|
||||||
|
m.route("/other/route");
|
||||||
|
```
|
||||||
|
|
||||||
|
### `v1.x`
|
||||||
|
|
||||||
|
```js
|
||||||
|
// Getting the current route
|
||||||
|
m.route.getPath();
|
||||||
|
|
||||||
|
// Setting a new route
|
||||||
|
m.route.setPath("/other/route");
|
||||||
|
```
|
||||||
|
|
||||||
|
## Accessing route params
|
||||||
|
|
||||||
|
In `v0.2.x` reading route params was all handled through the `m.route.param()` method. In `v1.x` any route params are passed as the `attrs` object on the vnode passed as the first argument to lifecycle methods/`view`.
|
||||||
|
|
||||||
|
### `v0.2.x`
|
||||||
|
|
||||||
|
```js
|
||||||
|
m.route(document.body, "/booga", {
|
||||||
|
"/:attr" : {
|
||||||
|
view : function() {
|
||||||
|
m.route.param("attr"); // "booga"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### `v1.x`
|
||||||
|
|
||||||
|
```js
|
||||||
|
m.route(document.body, "/booga", {
|
||||||
|
"/:attr" : {
|
||||||
|
oninit : function(vnode) {
|
||||||
|
vnode.attrs.attr; // "booga"
|
||||||
|
},
|
||||||
|
view : function(vnode) {
|
||||||
|
vnode.attrs.attr; // "booga"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue