Home  >  Article  >  Web Front-end  >  What is the difference between go and back in vue

What is the difference between go and back in vue

WBOY
WBOYOriginal
2022-03-17 15:00:143462browse

The difference between go and back in vue is: 1. Using go() to return to the original page will refresh the interface, while using back() to return to the original page will not refresh; 2. Using go() to return to the original page The content in the form will be lost, but the content in the form returned to the original page using back() will be retained.

What is the difference between go and back in vue

The operating environment of this article: Windows 10 system, Vue version 2.9.6, DELL G3 computer.

What is the difference between go and back in vue

When you encounter the need to return to the previous page during development, there are two methods to choose from:

1.$router. back()

2.$router.go()

It was found during use that using r o u t e r . b a c k ( ) and router.back () and router .back() and router.go(-1) have the same function, they both return to the original page. However, if the original page route carries parameters, the original page route parameters returned by the above two methods disappear. At this time, the original page route parameters returned by using $router.back(-1) still exist.

go(-1): The content in the original page form will be lost;

  • this.$router.go(-1): Back and refresh;

  • this.$router.go(0): Refresh;

  • this.$router.go(1): Forward

back(): The content in the original page form will be retained;

  • this.$router.back(): Back;

  • this.$router.back(0) Refresh;

  • this.$router.back(1): Forward

[Related recommendations: "vue.js tutorial"]

The above is the detailed content of What is the difference between go and back in vue. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn