onLoad新增参数callback, 解决react didmount中 ready取到oakfullpath
This commit is contained in:
parent
5ce89336a1
commit
454b48f0a2
|
|
@ -617,7 +617,7 @@ export function makePageMethods<
|
|||
}
|
||||
},
|
||||
|
||||
async onLoad(pageOption) {
|
||||
async onLoad(pageOption, callback) {
|
||||
const {
|
||||
oakId,
|
||||
oakEntity,
|
||||
|
|
@ -704,7 +704,7 @@ export function makePageMethods<
|
|||
id: oakId,
|
||||
});
|
||||
// const oakFullpath = oakParent ? `${oakParent}.${oakPath || options.path}` : oakPath || options.path;
|
||||
this.setState(
|
||||
await this.setState(
|
||||
{
|
||||
oakEntity: node.getEntity(),
|
||||
oakFullpath: path2,
|
||||
|
|
@ -716,6 +716,7 @@ export function makePageMethods<
|
|||
},
|
||||
() => {
|
||||
this.refresh();
|
||||
callback && callback.call(this);
|
||||
}
|
||||
);
|
||||
options.methods?.onLoad && options.methods.onLoad.call(this, pageOption);
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ function makeCommonComponentMethods<
|
|||
const { delta } = option || {};
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
this.props.navigateBack(delta || -1);
|
||||
this.props.navigate(delta || -1);
|
||||
resolve(undefined);
|
||||
} catch (err) {
|
||||
reject(err);
|
||||
|
|
@ -156,9 +156,6 @@ function makePageMethods<
|
|||
return {
|
||||
async onPullDownRefresh() {
|
||||
await onPullDownRefresh.call(this);
|
||||
if (!this.state.oakLoading) {
|
||||
await wx.stopPullDownRefresh();
|
||||
}
|
||||
},
|
||||
...rest,
|
||||
};
|
||||
|
|
@ -317,11 +314,12 @@ export function createPage<
|
|||
}
|
||||
|
||||
async componentDidMount() {
|
||||
await onLoad.call(this, this.props);
|
||||
methods?.onLoad && await methods.onLoad.call(this, this.props);
|
||||
methods?.onReady && await methods.onReady.call(this);
|
||||
lifetimes?.ready && await lifetimes.ready.call(this);
|
||||
pageLifetimes?.show && await pageLifetimes.show.call(this);
|
||||
await onLoad.call(this, this.props, () => {
|
||||
methods?.onLoad && methods.onLoad.call(this, this.props);
|
||||
methods?.onReady && methods.onReady.call(this);
|
||||
lifetimes?.ready && lifetimes.ready.call(this);
|
||||
pageLifetimes?.show && pageLifetimes.show.call(this);
|
||||
});
|
||||
}
|
||||
|
||||
async componentWillUnmount() {
|
||||
|
|
|
|||
|
|
@ -256,7 +256,10 @@ export type OakPageMethods = {
|
|||
refresh: (extra?: any) => Promise<void>;
|
||||
onPullDownRefresh: () => Promise<void>;
|
||||
onReachBottom: () => Promise<void>;
|
||||
onLoad: (options: Record<string, string | undefined>) => Promise<void>;
|
||||
onLoad: (
|
||||
options: Record<string, string | undefined>,
|
||||
callback?: () => void
|
||||
) => Promise<void>;
|
||||
};
|
||||
|
||||
export type OakComponentInstanceProperties<
|
||||
|
|
|
|||
Loading…
Reference in New Issue