uniapp returns to the specified page to save the page state

The uniapp history page falls back to the specified page.
insert image description here
insert image description here
getCurrentPages() The content is as follows

insert image description here
insert image description here

let delta = getCurrentPages().reverse().findIndex(item => 
	item.route ==="pages/popularScience/daodi"
		)
if(delta===-1){
    
    
	uni.navigateTo({
    
    
		url: '/pages/popularScience/daodi',
		success: res => {
    
    },
		fail: () => {
    
    },
		complete: () => {
    
    }
	});
}else{
    
    
	uni.navigateBack({
    
    
		delta: delta
	});
}

Guess you like

Origin blog.csdn.net/w710537643/article/details/132428496