Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
manulife-weapp
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
hookehuyr
2026-02-12 19:54:41 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
023a897f4fca5c6acf792bdd38823d1ece0b3560
023a897f
1 parent
cd642f0a
fix(login): fix back button issue
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
1 deletions
src/components/navigation/NavHeader.vue
src/pages/login/index.vue
src/components/navigation/NavHeader.vue
View file @
023a897
...
...
@@ -38,6 +38,7 @@ import IconFont from '@/components/icons/IconFont.vue'
* @property {String} [background] - Custom background style (CSS value)
* @property {String} [textColor] - Custom text/icon color (default #fff)
* @property {Boolean} [overlay] - Whether to overlay content (no placeholder)
* @property {Boolean} [preventDefaultBack] - Whether to prevent default navigateBack when @back is emitted
*/
const
props
=
defineProps
({
title
:
{
...
...
@@ -59,9 +60,15 @@ const props = defineProps({
overlay
:
{
type
:
Boolean
,
default
:
false
},
preventDefaultBack
:
{
type
:
Boolean
,
default
:
false
}
})
const
emit
=
defineEmits
([
'
back
'
])
const
canGoBack
=
ref
(
false
)
/**
...
...
@@ -77,6 +84,14 @@ onMounted(() => {
})
const
goBack
=
()
=>
{
// 触发 back 事件
// 父组件可以通过 @back 自定义返回行为
// 例如:登录页可以跳转到首页而非返回上一页
emit
(
'
back
'
)
// 如果没有阻止默认行为,执行默认的 navigateBack
if
(
!
props
.
preventDefaultBack
)
{
Taro
.
navigateBack
()
}
}
</
script
>
...
...
src/pages/login/index.vue
View file @
023a897
<template>
<view class="min-h-screen bg-white flex flex-col">
<!-- Header -->
<NavHeader title="" :show-back="true" />
<NavHeader title="" :show-back="true"
:prevent-default-back="true" @back="handleBack"
/>
<view class="flex-1 flex flex-col px-[48rpx] pt-[120rpx]">
<!-- Logo/Title -->
...
...
@@ -80,6 +80,20 @@ const form = reactive({
})
/**
* Handle back button click
* - 清空 router store 中保存的路径
* - 跳转到首页(因为导航栈已被 401 清空)
*/
const handleBack = () => {
// 清空保存的路径
const store = routerStore()
store.remove()
// 跳转到首页
Taro.reLaunch({ url: '/pages/index/index' })
}
/**
* Handle login action
*/
const handleLogin = async () => {
...
...
Please
register
or
login
to post a comment