“Vue Router Push” Code-Antworten

Vue Router Push

//Syntax - this.$router.push(path);
this.$router.push("/path");
iamhanumanth

Programmatische Navigation Vue Router

// literal string path
router.push('home')

// object
router.push({ path: 'home' })

// named route
router.push({ name: 'user', params: { userId: '123' } })

// with query, resulting in /register?plan=private
router.push({ path: 'register', query: { plan: 'private' } })
Nate

Vue Router Push

const username = 'eduardo'
// we can manually build the url but we will have to handle the encoding ourselves
router.push(`/user/${username}`) // -> /user/eduardo
// same as
router.push({ path: `/user/${username}` }) // -> /user/eduardo
// if possible use `name` and `params` to benefit from automatic URL encoding
router.push({ name: 'user', params: { username } }) // -> /user/eduardo
// `params` cannot be used alongside `path`
router.push({ path: '/user', params: { username } }) // -> /user
SimonAngatia

Ähnliche Antworten wie “Vue Router Push”

Fragen ähnlich wie “Vue Router Push”

Weitere verwandte Antworten zu “Vue Router Push” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen