提交 cdaf4c4c 编写于 作者: Q qiang

fix(x): iOS 延迟页面 vm 创建

上级 9a18d49a
......@@ -74,7 +74,9 @@ function _navigateTo({
// 有动画时先执行 show
const page = registerPage(
{ url, path, query, openType: 'navigateTo', eventChannel },
noAnimation ? undefined : callback
noAnimation ? undefined : callback,
// 有动画时延迟创建 vm
noAnimation ? 1 : 0
)
if (noAnimation) {
callback(page)
......
......@@ -96,7 +96,8 @@ export function registerPage(
nvuePageVm,
eventChannel,
}: RegisterPageOptions,
onCreated?: (page: IPage) => void
onCreated?: (page: IPage) => void,
delay = 0
) {
const id = genWebviewId()
const routeOptions = initRouteOptions(path, openType)
......@@ -122,47 +123,53 @@ export function registerPage(
// TODO ThemeMode
'light'
)
const page = createVuePage(
id,
route,
query,
pageInstance,
{},
nativePage
) as ComponentPublicInstance
nativePage.addPageEventListener(ON_SHOW, (_) => {
invokeHook(page, ON_SHOW)
})
nativePage.addPageEventListener(ON_POP_GESTURE, function (e) {
uni.navigateBack({
from: 'popGesture',
fail(e) {
if (e.errMsg.endsWith('cancel')) {
nativePage.show()
}
},
} as UniApp.NavigateBackOptions)
})
nativePage.addPageEventListener(ON_UNLOAD, (_) => {
invokeHook(page, ON_UNLOAD)
})
nativePage.addPageEventListener(ON_READY, (_) => {
invokeHook(page, ON_READY)
})
function fn() {
const page = createVuePage(
id,
route,
query,
pageInstance,
{},
nativePage
) as ComponentPublicInstance
nativePage.addPageEventListener(ON_PULL_DOWN_REFRESH, (_) => {
invokeHook(page, ON_PULL_DOWN_REFRESH)
})
nativePage.addPageEventListener(ON_SHOW, (_) => {
invokeHook(page, ON_SHOW)
})
nativePage.addPageEventListener(ON_POP_GESTURE, function (e) {
uni.navigateBack({
from: 'popGesture',
fail(e) {
if (e.errMsg.endsWith('cancel')) {
nativePage.show()
}
},
} as UniApp.NavigateBackOptions)
})
nativePage.addPageEventListener(ON_UNLOAD, (_) => {
invokeHook(page, ON_UNLOAD)
})
nativePage.addPageEventListener(ON_READY, (_) => {
invokeHook(page, ON_READY)
})
nativePage.addPageEventListener(ON_REACH_BOTTOM, (_) => {
invokeHook(page, ON_REACH_BOTTOM)
})
nativePage.addPageEventListener(ON_PULL_DOWN_REFRESH, (_) => {
invokeHook(page, ON_PULL_DOWN_REFRESH)
})
nativePage.addPageEventListener(ON_RESIZE, (_) => {
invokeHook(page, ON_RESIZE)
})
nativePage.addPageEventListener(ON_REACH_BOTTOM, (_) => {
invokeHook(page, ON_REACH_BOTTOM)
})
nativePage.addPageEventListener(ON_RESIZE, (_) => {
invokeHook(page, ON_RESIZE)
})
}
if (delay) {
setTimeout(fn, delay)
} else {
fn()
}
return nativePage
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册