Merge branch 'dev' of codeup.aliyun.com:61c14a7efa282c88e103c23f/oak-frontend-base into dev

This commit is contained in:
Xu Chang 2023-12-01 12:33:10 +08:00
commit d96cd1c0f5
7 changed files with 24 additions and 21 deletions

View File

@ -7,14 +7,15 @@ export class Navigator extends CommonNavigator {
this.history = wx;
}
getLocation() {
//初始化的时候
const pages = getCurrentPages(); //获取加载的页面
const currentPage = pages[pages.length - 1]; //获取当前页面的对象
const url = currentPage.route; //当前页面url
const options = currentPage.options; //如果要获取url中所带的参数可以查看options
const pathname = url
const url = currentPage?.route; //当前页面url
const options = currentPage?.options; //如果要获取url中所带的参数可以查看options
const pathname = url ? url
.replace('/pages', '')
.replace('pages', '')
.replace('/index', '');
.replace('/index', '') : '';
return {
pathname: pathname,
state: options,

View File

@ -17,8 +17,8 @@ export class Navigator extends CommonNavigator {
getLocation() {
const route = this.history.getCurrentRoute();
return {
pathname: route.name,
state: route.params,
pathname: route?.name,
state: route?.params,
};
}
getState() {

View File

@ -10,14 +10,15 @@ class Navigator extends navigator_common_1.Navigator {
this.history = wx;
}
getLocation() {
//初始化的时候
const pages = getCurrentPages(); //获取加载的页面
const currentPage = pages[pages.length - 1]; //获取当前页面的对象
const url = currentPage.route; //当前页面url
const options = currentPage.options; //如果要获取url中所带的参数可以查看options
const pathname = url
const url = currentPage?.route; //当前页面url
const options = currentPage?.options; //如果要获取url中所带的参数可以查看options
const pathname = url ? url
.replace('/pages', '')
.replace('pages', '')
.replace('/index', '');
.replace('/index', '') : '';
return {
pathname: pathname,
state: options,

View File

@ -20,8 +20,8 @@ class Navigator extends navigator_common_1.Navigator {
getLocation() {
const route = this.history.getCurrentRoute();
return {
pathname: route.name,
state: route.params,
pathname: route?.name,
state: route?.params,
};
}
getState() {

View File

@ -19,14 +19,15 @@ export class Navigator extends CommonNavigator {
}
getLocation(): Location {
//初始化的时候
const pages = getCurrentPages(); //获取加载的页面
const currentPage = pages[pages.length - 1]; //获取当前页面的对象
const url = currentPage.route; //当前页面url
const options = currentPage.options; //如果要获取url中所带的参数可以查看options
const pathname = url
const url = currentPage?.route; //当前页面url
const options = currentPage?.options; //如果要获取url中所带的参数可以查看options
const pathname = url ? url
.replace('/pages', '')
.replace('pages', '')
.replace('/index', '');
.replace('/index', '') : '';
return {
pathname: pathname,
state: options,
@ -36,7 +37,7 @@ export class Navigator extends CommonNavigator {
getState() {
const { pathname, state } = this.getLocation();
const state2 = this.constructState(pathname, state);
const state2 = this.constructState(pathname!, state);
return state2;
}

View File

@ -36,14 +36,14 @@ export class Navigator extends CommonNavigator {
getLocation() {
const route = this.history.getCurrentRoute()!;
return {
pathname: route.name,
state: route.params,
pathname: route?.name,
state: route?.params,
};
}
getState() {
const { pathname, state } = this.getLocation();
const state2 = this.constructState(pathname, state);
const state2 = this.constructState(pathname!, state);
return state2;
}

View File

@ -31,7 +31,7 @@ export class Navigator extends CommonNavigator {
getState() {
const { pathname, state, search } = this.getLocation();
const state2 = this.constructState(
pathname,
pathname!,
state as Record<string, any>,
search
);