提交 6a05ddc1 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

fix(navigateBack): 修复 navigateBack options ts 类型可选引发的 ts 错误

上级 a94a4764
...@@ -40,9 +40,11 @@ export const navigateBack = defineAsyncApi<API_TYPE_NAVIGATE_BACK>( ...@@ -40,9 +40,11 @@ export const navigateBack = defineAsyncApi<API_TYPE_NAVIGATE_BACK>(
quit() quit()
} else if (isDirectPage(page)) { } else if (isDirectPage(page)) {
reLaunchEntryPage() reLaunchEntryPage()
} else { } else if (args) {
const { delta, animationType, animationDuration } = args const { delta, animationType, animationDuration } = args
back(delta!, animationType, animationDuration) back(delta!, animationType, animationDuration)
} else {
back()
} }
return resolve() return resolve()
}, },
...@@ -65,7 +67,7 @@ function quit() { ...@@ -65,7 +67,7 @@ function quit() {
} }
function back( function back(
delta: number, delta: number = 1,
animationType?: string, animationType?: string,
animationDuration?: number animationDuration?: number
) { ) {
......
...@@ -33,7 +33,17 @@ const ANIMATION_OUT = [ ...@@ -33,7 +33,17 @@ const ANIMATION_OUT = [
] ]
type AnimationToType = Parameters<typeof uni.navigateTo>[0]['animationType'] type AnimationToType = Parameters<typeof uni.navigateTo>[0]['animationType']
type AnimationBackType = Parameters<typeof uni.navigateBack>[0]['animationType'] type AnimationBackType =
| 'auto'
| 'none'
| 'slide-out-right'
| 'slide-out-left'
| 'slide-out-top'
| 'slide-out-bottom'
| 'fade-out'
| 'zoom-in'
| 'zoom-fade-in'
| 'pop-out'
export const navigatorProps = { export const navigatorProps = {
hoverClass: { hoverClass: {
......
...@@ -23,7 +23,7 @@ export const navigateBack = defineAsyncApi<API_TYPE_NAVIGATE_BACK>( ...@@ -23,7 +23,7 @@ export const navigateBack = defineAsyncApi<API_TYPE_NAVIGATE_BACK>(
return reject(ON_BACK_PRESS) return reject(ON_BACK_PRESS)
} }
getApp().$router.go(-args.delta!) getApp().$router.go(args && args.delta ? -args.delta : -1)
return resolve() return resolve()
}, },
NavigateBackProtocol, NavigateBackProtocol,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册