移除小程序pageLifetimes中 show、hide函数的断言

This commit is contained in:
Wang Kejun 2023-11-03 19:52:28 +08:00
parent 236078498d
commit 92a5bdc629
3 changed files with 18 additions and 15 deletions

View File

@ -491,13 +491,11 @@ const oakBehavior = Behavior({
pageLifetimes: {
show() {
const { show } = this.oakOption.lifetimes || {};
// this.reRender();
assert(this.state.oakFullpath, '组件不应当在oakPath没确定前就渲染');
this.reRender();
show && show.call(this);
},
hide() {
const { hide } = this.oakOption.lifetimes || {};
assert(this.state.oakFullpath, '组件不应当在oakPath没确定前就渲染');
hide && hide.call(this);
},
},
@ -700,11 +698,13 @@ export function createComponent(option, features) {
},
ready() {
if (typeof data === 'function') {
// ts的编译好像有问题这里不硬写as过不去
// ts的编译好像有问题这里不硬写as过不去
const data2 = data.call(this);
this.setData(data2);
}
assert(this.state.oakFullpath, '组件不应当在oakPath没确定前就渲染');
if (this.props.oakPath) {
assert(this.state.oakFullpath, '组件不应当在oakPath没确定前就渲染');
}
ready && ready.call(this);
},
moved() {

View File

@ -494,13 +494,11 @@ const oakBehavior = Behavior({
pageLifetimes: {
show() {
const { show } = this.oakOption.lifetimes || {};
// this.reRender();
(0, assert_1.assert)(this.state.oakFullpath, '组件不应当在oakPath没确定前就渲染');
this.reRender();
show && show.call(this);
},
hide() {
const { hide } = this.oakOption.lifetimes || {};
(0, assert_1.assert)(this.state.oakFullpath, '组件不应当在oakPath没确定前就渲染');
hide && hide.call(this);
},
},
@ -703,11 +701,13 @@ function createComponent(option, features) {
},
ready() {
if (typeof data === 'function') {
// ts的编译好像有问题这里不硬写as过不去
// ts的编译好像有问题这里不硬写as过不去
const data2 = data.call(this);
this.setData(data2);
}
(0, assert_1.assert)(this.state.oakFullpath, '组件不应当在oakPath没确定前就渲染');
if (this.props.oakPath) {
(0, assert_1.assert)(this.state.oakFullpath, '组件不应当在oakPath没确定前就渲染');
}
ready && ready.call(this);
},
moved() {

View File

@ -727,13 +727,11 @@ const oakBehavior = Behavior<
pageLifetimes: {
show() {
const { show } = this.oakOption.lifetimes || {};
// this.reRender();
assert(this.state.oakFullpath, '组件不应当在oakPath没确定前就渲染');
this.reRender();
show && show.call(this);
},
hide() {
const { hide } = this.oakOption.lifetimes || {};
assert(this.state.oakFullpath, '组件不应当在oakPath没确定前就渲染');
hide && hide.call(this);
},
},
@ -1050,11 +1048,16 @@ export function createComponent<
},
ready() {
if (typeof data === 'function') {
// ts的编译好像有问题这里不硬写as过不去
// ts的编译好像有问题这里不硬写as过不去
const data2 = (data as Function).call(this as any);
this.setData(data2);
}
assert(this.state.oakFullpath, '组件不应当在oakPath没确定前就渲染');
if (this.props.oakPath) {
assert(
this.state.oakFullpath,
'组件不应当在oakPath没确定前就渲染'
);
}
ready && ready.call(this);
},
moved() {