Vue.js: redirection to another page

Vue.js: redirection to another page

Asked on November 17, 2018 in vue.js.
Add Comment


  • 2 Answer(s)

    While manipulating via vue-router, you must utilize router.go(path) to traverse to another specific route. Router is retrieved as of inside element utilizing this.$router.

    Else, window.location.href = ‘some url’; everything perform well for non-single-page apps.

    Check it out:

    router.go() altered in VueJS 2.0. Apply router.push({ name: “yourroutename”}) or just router.push(“yourroutename”) to redirect.

    Answered on November 17, 2018.
    Add Comment

    As per vue.js documents, router.push looks as an ideal technique.

    If you want to traverse to other URL, utilize router.push. It will push the content as new data in history stack, after that while clicking back button in a browser it navigates to former URL.

    Webpack & module setup, single page app, call the router methods by:

    this.$router
    

    For instance, suppose you may need to traverse to route known as “Home” later criteria is encountered.

    this.$router.push('Home')
    
    Answered on November 17, 2018.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.