提交 260f39cb 编写于 作者: fxy060608's avatar fxy060608

fix(h5): onPageScroll not working in component setup

上级 d5964629
......@@ -13933,25 +13933,17 @@ function setupPage(comp) {
instance2.root = instance2;
const route = usePageRoute();
const pageMeta = usePageMeta();
onBeforeMount(() => {
onMounted(() => {
onPageShow(instance2, pageMeta);
const { onLoad, onShow } = instance2;
onLoad && invokeArrayFns$1(onLoad, decodedQuery(route.query));
instance2.__isVisible = true;
if (onShow) {
nextTick(() => {
invokeArrayFns$1(onShow);
});
}
onShow && invokeArrayFns$1(onShow);
});
onMounted(() => {
onPageReady(instance2);
const { onReady } = instance2;
if (onReady) {
nextTick(() => {
invokeArrayFns$1(onReady);
});
}
onReady && invokeArrayFns$1(onReady);
});
onBeforeActivate(() => {
if (!instance2.__isVisible) {
......
......@@ -90,28 +90,18 @@ export function setupPage(comp: any) {
}
const pageMeta = usePageMeta()
onBeforeMount(() => {
// 放在 onMounted 中,可以保证子组件中监听的相关生命周期也可以触发,比如onShow,onPageScroll
onMounted(() => {
onPageShow(instance, pageMeta)
const { onLoad, onShow } = instance
onLoad && invokeArrayFns(onLoad, decodedQuery(route.query))
instance.__isVisible = true
if (onShow) {
// 延迟onShow,保证子组件的首次onShow也能生效
nextTick(() => {
invokeArrayFns(onShow)
})
}
onShow && invokeArrayFns(onShow)
})
onMounted(() => {
onPageReady(instance)
const { onReady } = instance
if (onReady) {
// 因为onShow被延迟,故onReady也延迟,否则会出现onReady比onShow还早
nextTick(() => {
invokeArrayFns(onReady)
})
}
onReady && invokeArrayFns(onReady)
})
onBeforeActivate(() => {
if (!instance.__isVisible) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册