getLocation方法中返回search

This commit is contained in:
Xu Chang 2024-07-01 12:26:35 +08:00
parent 98d9ce36d0
commit feaf8c9b87
2 changed files with 17 additions and 0 deletions

View File

@ -16,11 +16,19 @@ export class Navigator extends CommonNavigator {
.replace('/pages', '')
.replace('pages', '')
.replace('/index', '') : '';
let search = '';
for (const k in options) {
if (search) {
search += '&';
}
search += `${k}=${ typeof options[k] === 'string' ? options[k] : JSON.stringify(options[k])}`;
}
return {
pathname: pathname,
state: options,
key: `${pages.length - 1}`,
namespace: this.namespace,
search,
};
}
getState() {

View File

@ -9,6 +9,7 @@ type Location = {
state?: Record<string, any>;
key: string;
namespace: string;
search: string;
};
export class Navigator extends CommonNavigator {
@ -29,11 +30,19 @@ export class Navigator extends CommonNavigator {
.replace('/pages', '')
.replace('pages', '')
.replace('/index', '') : '';
let search = '';
for (const k in options) {
if (search) {
search += '&';
}
search += `${k}=${ typeof options[k] === 'string' ? options[k] : JSON.stringify(options[k])}`;
}
return {
pathname: pathname,
state: options,
key: `${pages.length - 1}`,
namespace: this.namespace,
search,
};
}