After the iview has a paged list jump, how to keep the last page turning record when returning

In actual use, when we edit this information from a certain page of the list, do we return to the list page when the editing is completed, then which page of data should be displayed on the list page? Of course, we want to return to the position of the previous page count, not the home page.

If I edit a certain record and save it now, what I want is to return to the third page. In fact, the master needs to save the last record of the page number of the page turned in the localstorage to solve this problem.

code show as below:

setContextData: function(key, value) {
   let val = value ? value : 1
   localSave(key,JSON.stringify(val))
},
getContextData: function(key){
    return localRead(key) ? parseInt(JSON.parse(localRead(key))) : 1
},
mounted方法里面初始化的时候记录当前页码:
initList(){
    let pageSize = this.pageSize;
    let page = this.getContextData("currentPage");
    let search_from = this.formSearch;
    this.getData(page, pageSize, search_from) // 初始化请求
},

 

This ensures that after a certain page operation is completed, we return to the page of the last operation, not the home page.

Guess you like

Origin blog.csdn.net/lchmyhua88/article/details/110824851