How to return to the previous page in vue

How to control the current page to return to the previous routing page by clicking:

Insert picture description here
1. Add a back button to the current page

<div style="text-align: center">
  <el-button v-on:click="backHistory">取消</el-button>
</div>

2. Write the back method in the method body to realize the operation of clicking to return to the previous page

methods:{
    
    
  backHistory(){
    
    
    this.$router.go(-1);//返回上一层
  },
},

Summary:
this.$router.go(val) => Go forward or backward val steps in the history record. When val is 0, refresh the current page, -1 means return to the previous page;

go(-1): The content in the original page form will be lost;
history.go(-1): go back + refresh;

history.go (1): Advance

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

history.back(0) refresh;

history.back(1): forward
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_43248623/article/details/108992441