Skip to content

Commit

Permalink
[doc] update document of the navigator module (apache#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanks10100 committed Feb 7, 2018
2 parents b2498a0 + b4d49cb commit 5b760b0
Showing 1 changed file with 27 additions and 56 deletions.
83 changes: 27 additions & 56 deletions source/references/modules/navigator.md
Expand Up @@ -16,83 +16,54 @@ And The navigator module mimics the same behaviors in the iOS/Android applicatio
## API
### push(options, callback)

push a weex page onto the navigator stack, you can specify whether apply animation when pushing. And you can also specify a callback function to be executed after the operation is over.
Push a weex page onto the navigator stack, you can specify whether apply animation when pushing. And you can also specify a callback function to be executed after the operation is over.

**parameters**
**Arguments**

* options(object): some options.
* url(stirng): The URL of the weex page to push.
* animated(string): true, if the weex page is push through animation, otherwise, false. Default value is true.

* callback(object): the callback function to be called after executing this action.

**Example**

```html
var navigator = weex.requireModule('navigator')
var modal = weex.requireModule('modal')
var bundleUrl = weex.config.bundleUrl;
navigator.push({
url: bundleUrl,
animated: "true"
}, event => {
modal.toast({ message: 'callback: ' + event })
})
```

### pop(options, callback)

pop a weex page onto the navigator stack, you can specify whether apply animation when popping. And you can also specify a callback function to be executed after the operation is over.

**parameters**
**Arguments**

* options(object): some options.
* animated(string): true if the weex page is pop through animation; otherwise, false. Default value is true.
* callback(object): the callback function after executing this action.


## Example
**Example**

```html
<template>
<div class="wrapper">
<text class="button" @click="push">Push</text>
<text class="button" @click="pop">Pop</text>
</div>
</template>

<script>
var navigator = weex.requireModule('navigator')
var modal = weex.requireModule('modal')
export default {
methods: {
push (event) {
var bundleUrl = weex.config.bundleUrl;
navigator.push({
url: bundleUrl,
animated: "true"
var navigator = weex.requireModule('navigator')
var modal = weex.requireModule('modal')
navigator.pop({ animated: "true"
}, event => {
modal.toast({ message: 'callback: ' + event })
modal.toast({ message: 'callback: ' + event })
})
},
pop (event) {
navigator.pop({
animated: "true"
}, event => {
modal.toast({ message: 'callback: ' + event })
})
}
}
};
</script>

<style scoped>
.wrapper {
flex-direction: column;
justify-content: center;
}
.button {
font-size: 60px;
width: 450px;
text-align: center;
margin-top: 30px;
margin-left: 150px;
padding-top: 20px;
padding-bottom: 20px;
border-width: 2px;
border-style: solid;
color: #666666;
border-color: #DDDDDD;
background-color: #F5F5F5
}
</style>
```

## Notice
Due to the differences in the behavior of the navigation in clients, the above interfaces need to be adapted. You can implement the above interfaces on the client side by seeing the description of the navigation protocol.

In addtion,you can read [How to extend] (https://github.com/apache/incubator-weex-site/blob/master/source/guide/extend-ios.md) in iOS/Android to learn how to register the implementation the protocol on the client.

[try it](http://dotwe.org/vue/f2daa25e32eec2a294d59a9144660cad)

0 comments on commit 5b760b0

Please sign in to comment.