From aa5e70d5f64385356526b9c91440852d78cae57b Mon Sep 17 00:00:00 2001 From: minimaxagent1 Date: Thu, 31 Jul 2025 09:15:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E5=AF=BC=E8=88=AA?= =?UTF-8?q?=E6=A0=8F=E8=AE=BE=E8=AE=A1=E7=BB=84=E4=BB=B6custom-navbar?= =?UTF-8?q?=E5=B0=81=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/custom-navbar/README.md | 98 ++++++++++++++++ components/custom-navbar/custom-navbar.vue | 130 +++++++++++++++++++++ pages/walkInto/walkInto.vue | 95 ++------------- 3 files changed, 239 insertions(+), 84 deletions(-) create mode 100644 components/custom-navbar/README.md create mode 100644 components/custom-navbar/custom-navbar.vue diff --git a/components/custom-navbar/README.md b/components/custom-navbar/README.md new file mode 100644 index 0000000..51ef383 --- /dev/null +++ b/components/custom-navbar/README.md @@ -0,0 +1,98 @@ +# CustomNavbar 自定义导航栏组件 + +## 功能特性 + +- 自动适配微信小程序状态栏高度 +- 自动计算胶囊按钮高度,确保文字与胶囊水平对齐 +- 支持自定义标题、返回按钮图标 +- 支持右侧插槽,可添加自定义内容 +- 支持返回事件回调 + +## 使用方法 + +### 基础用法 + +```vue + + + +``` + +### 自定义返回按钮图标 + +```vue + +``` + +### 隐藏返回按钮 + +```vue + +``` + +### 添加右侧内容 + +```vue + + + +``` + +## Props + +| 参数 | 类型 | 默认值 | 说明 | +|------|------|--------|------| +| title | String | '' | 导航栏标题 | +| backIcon | String | CommonEnum.BACK_BUTTON | 返回按钮图标路径 | +| showBack | Boolean | true | 是否显示返回按钮 | + +## Events + +| 事件名 | 说明 | 回调参数 | +|--------|------|----------| +| back | 点击返回按钮时触发 | - | + +## Slots + +| 插槽名 | 说明 | +|--------|------| +| right | 右侧内容插槽 | + +## 注意事项 + +1. 组件会自动计算状态栏和胶囊高度,无需手动设置 +2. 组件使用 `position: fixed` 定位,确保在页面顶部 +3. 组件内部包含填充区,页面内容无需设置 `margin-top` +4. 组件样式使用 `scoped`,不会影响其他组件 \ No newline at end of file diff --git a/components/custom-navbar/custom-navbar.vue b/components/custom-navbar/custom-navbar.vue new file mode 100644 index 0000000..ace9b51 --- /dev/null +++ b/components/custom-navbar/custom-navbar.vue @@ -0,0 +1,130 @@ + + + + + \ No newline at end of file diff --git a/pages/walkInto/walkInto.vue b/pages/walkInto/walkInto.vue index f015277..b552bde 100644 --- a/pages/walkInto/walkInto.vue +++ b/pages/walkInto/walkInto.vue @@ -1,15 +1,12 @@