Skip to content

Traduction de api/route-object.md #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/en/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
- Réference de l'API
- [router-link (En)](api/router-link.md)
- [router-view (En)](api/router-view.md)
- [The Route Object (En)](api/route-object.md)
- [L'objet Route](api/route-object.md)
- [Router Constructor Options (En)](api/options.md)
- [Router Instance (En)](api/router-instance.md)
- [Component Injections (En)](api/component-injections.md)
58 changes: 29 additions & 29 deletions docs/en/api/route-object.md
Original file line number Diff line number Diff line change
@@ -1,89 +1,89 @@
# The Route Object (En) <br><br> *Cette page est en cours de traduction française. Revenez une autre fois pour lire une traduction achevée ou [participez à la traduction française ici](https://github.com/vuejs-fr/vue-router).*
# L'objet `Route`

A **route object** represents the state of the current active route. It contains parsed information of the current URL and the **route records** matched by the URL.
Un **objet `Route`** représente l'état actuel de la route active. Il contient des informations analysées à propos de l'URL courante et **les itinéraires de route** appariés par l'URL.

The route object is immutable. Every successful navigation will result in a fresh route object.
L'objet `Route` est immutable. Chaque navigation qui se déroule avec succès résultera en un nouvel objet `Route`.

The route object can be found in multiple places:
L'objet `Route` peut être trouvé à plusieurs endroits :

- Inside components as `this.$route`
- À l'intérieur des composants en tant que `this.$route`

- Inside `$route` watcher callbacks
- À l'intérieur des fonctions de rappel des observateurs de `$route`

- As the return value of calling `router.match(location)`
- Comme valeur de retour après l'appel de `router.match(location)`

- Inside navigation guards as the first two arguments:
- À l'intérieur des fonctions de sécurisation de la navigation, dans les deux premiers paramètres de la fonction :

``` js
router.beforeEach((to, from, next) => {
// to and from are both route objects
// `to` et `from` sont tous les deux des objets Route
})
```

- Inside the `scrollBehavior` function as the first two arguments:
- À l'intérieur de la fonction `scrollBehavior` dans les deux premiers arguments :

``` js
const router = new VueRouter({
scrollBehavior (to, from, savedPosition) {
// to and from are both route objects
// `to` et `from` sont tous les deux des objets Route
}
})
```

### Route Object Properties
### Propriétés de l'objet `Route`

- **$route.path**

- type: `string`
- type : `string`

A string that equals the path of the current route, always resolved as an absolute path. e.g. `"/foo/bar"`.
Une chaîne de caractères représentant le chemin de la route en cours, toujours résolue en tant que chemin absolu, ex : `"/foo/bar"`.

- **$route.params**

- type: `Object`
- type : `Object`

An object that contains key/value pairs of dynamic segments and star segments. If there are no params the value will be an empty object.
Un objet qui contient des pairs clé/valeur de segments dynamiques et segments *star*. S'il n'y a pas de paramètres, alors la valeur sera un objet vide.

- **$route.query**

- type: `Object`

An object that contains key/value pairs of the query string. For example, for a path `/foo?user=1`, we get `$route.query.user == 1`. If there is no query the value will be an empty object.
- type : `Object`

Un objet qui contient des pairs clé/valeur de la requête au format d'une chaîne de caractères. Par exemple, pour un chemin `/foo?user=1`, on aura `$route.query.user == 1`. S'il n'y a pas de requête, alors la valeur sera un objet vide.

- **$route.hash**

- type: `string`
- type : `string`

The hash of the current route (with the `#`), if it has one. If no hash is present the value will be an empty string.
Le hash de la route courante (avec le `#`), s'il y en a un. S'il n'y a pas de hash, alors la valeur sera une chaîne de caractères vide.

- **$route.fullPath**

- type: `string`
- type : `string`

The full resolved URL including query and hash.
L'URL entièrement résolue, incluant la requête et le hash.

- **$route.matched**

- type: `Array<RouteRecord>`
- type : `Array<RouteRecord>`

An Array containing **route records** for all nested path segments of the current route. Route records are the copies of the objects in the `routes` configuration Array (and in `children` Arrays):
Un `Array` contenant les **les itinéraires de la route** pour chaque segment de chemin imbriqué de la route courante. Les itinéraires de la route sont des copies des objets dans le tableau de configuration `routes` (et dans les tableaux `children`).

``` js
const router = new VueRouter({
routes: [
// the following object is a route record
// l'objet qui suit est un itinéraire de route
{ path: '/foo', component: Foo,
children: [
// this is also a route record
// c'est aussi un itinéraire
{ path: 'bar', component: Bar }
]
}
]
})
```

When the URL is `/foo/bar`, `$route.matched` will be an Array containing both objects (cloned), in parent to child order.
Lorsque l'URL sera `/foo/bar`, `$route.matched` sera un `Array` contenant les deux objets (clonés), dans l'ordre parent à l'enfant.

- **$route.name**

The name of the current route, if it has one. (See [Named Routes](../essentials/named-routes.md))
Le nom de la route courante, si elle en a un. (Voir [Routes nommées](../essentials/named-routes.md)).