forked from vuejs/vue-router
-
Notifications
You must be signed in to change notification settings - Fork 2
Traduction de named-routes.md
#18
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
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,31 @@ | ||
# Named Routes (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).* | ||
# Routes nommées | ||
|
||
Sometimes it is more convenient to identify a route with a name, especially when linking to a route or performing navigations. You can give a route a name in the `routes` options while creating the Router instance: | ||
Parfois il est plus pratique d'identifer une route avec un nom, tout particulièrement quand on souhaite attacher cette route ou exécuter des actions de navigation. Vous pouvez donner à une route un nom dans les options `routes` pendant la création de l'instance du routeur : | ||
|
||
``` js | ||
const router = new VueRouter({ | ||
routes: [ | ||
{ | ||
path: '/user/:userId', | ||
path: '/utilisateur/:userId', | ||
name: 'user', | ||
component: User | ||
} | ||
] | ||
}) | ||
``` | ||
|
||
To link to a named route, you can pass an object to the `router-link` | ||
component's `to` prop: | ||
Pour attacher une route nommée, vous pouvez passer un objet à la prop `to` du composant `router-link` : | ||
|
||
``` html | ||
<router-link :to="{ name: 'user', params: { userId: 123 }}">User</router-link> | ||
<router-link :to="{ name: 'user', params: { userId: 123 }}">Utilisateur</router-link> | ||
``` | ||
|
||
This is the exact same object used programatically with `router.push()`: | ||
C'est exactement le même objet à utiliser programmatiquement avec `router.push()` : | ||
|
||
``` js | ||
router.push({ name: 'user', params: { userId: 123 }}) | ||
``` | ||
|
||
In both cases, the router will navigate to the path `/user/123`. | ||
Dans les deux cas, le routeur va naviguer vers le chemin `/utilisateur/123`. | ||
|
||
Full example [here](https://github.com/vuejs/vue-router/blob/dev/examples/named-routes/app.js). | ||
Un exemple complet se trouve [ici](https://github.com/vuejs/vue-router/blob/dev/examples/named-routes/app.js). |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.