I'd like to make a redirection in Vue.js
similar to the vanilla javascript
window.location.href = 'some_url'
How could I achieve this in Vue.js?
I'd like to make a redirection in Vue.js
similar to the vanilla javascript
window.location.href = 'some_url'
How could I achieve this in Vue.js?
If you are using
vue-router
, you should userouter.go(path)
to navigate to any particular route. The router can be accessed from within a component usingthis.$router
.Otherwise,
window.location.href = 'some url';
works fine for non single-page apps.EDIT:
router.go()
changed in VueJS 2.0. You can userouter.push({ name: "yourroutename"})
or justrouter.push("yourroutename")
now to redirect.https://router.vuejs.org/guide/essentials/named-routes.html