search

Home  >  Q&A  >  body text

javascript - vue-router routing jump problem

There is a return button in the upper left corner. When clicked, you will return to the previous route.

What I want is to use router.go(-1);

But if you open Baidu at the beginning, and then open this page, you will return to Baidu. That does not work.

What I want to solve is to click the return button. If there is no route, you cannot jump. Don't know the idea.

阿神阿神2768 days ago669

reply all(1)I'll reply

  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-19 10:38:34

    For security reasons, we cannot directly obtain the information in the history and can only jump backward through exposed methods;

    One of my ideas is to use the method exposed by the router beforeRouterLeave to make judgments in conjunction with the current route to prevent jumps.

    reply
    0
  • Cancelreply