封装导航栏的应用

This commit is contained in:
minimaxagent1 2025-07-31 09:27:55 +08:00
parent aa5e70d5f6
commit 540e05c282
5 changed files with 16 additions and 20 deletions

View File

@ -15,7 +15,7 @@
```vue
<template>
<view class="page">
<custom-navbar title="页面标题" @back="onBack" />
<custom-navbar title="页面标题" />
<!-- 页面内容,无需设置 margin-top -->
<view class="content">
<text>页面内容</text>
@ -29,11 +29,6 @@ import CustomNavbar from "@/components/custom-navbar/custom-navbar.vue";
export default {
components: {
CustomNavbar
},
methods: {
onBack() {
console.log('返回按钮被点击');
}
}
}
</script>
@ -45,7 +40,6 @@ export default {
<custom-navbar
title="页面标题"
:backIcon="customBackIcon"
@back="onBack"
/>
```
@ -61,7 +55,7 @@ export default {
### 添加右侧内容
```vue
<custom-navbar title="页面标题" @back="onBack">
<custom-navbar title="页面标题">
<template #right>
<view class="right-content">
<text>右侧内容</text>
@ -82,7 +76,7 @@ export default {
| 事件名 | 说明 | 回调参数 |
|--------|------|----------|
| back | 点击返回按钮时触发 | - |
| back | 点击返回按钮时触发(可选,组件会自动执行返回逻辑) | - |
## Slots

View File

@ -64,7 +64,9 @@ export default {
},
handleBack() {
if (this.showBack) {
//
this.$emit('back');
//
uni.navigateBack({
delta: 1
});

View File

@ -1,8 +1,6 @@
<template>
<view class="page">
<u-navbar title="建制" :border-bottom="false" :background="bgc" back-icon-color="#262B37" title-color='#695347'
title-size='36' height='50' :title-style="{ fontWeight: 2000 }" id="navbar">
</u-navbar>
<custom-navbar title="建制" />
<view class="tile">
<view class="tile-item" v-for="(item, index) in 10" :key="index">
<image :src="tilesImageEnum.TILE" mode="aspectFit" class="tile-image"></image>
@ -44,8 +42,12 @@
<script>
import { tilesImageEnum } from '@/enum/institutionalStructure.js';
import { getInstitutionalList } from '@/api/institutionalStructure.js';
import CustomNavbar from "../../components/custom-navbar/custom-navbar.vue";
export default {
components: {
CustomNavbar
},
data() {
return {
bgc: {

View File

@ -4,9 +4,7 @@
<image class="bg-image" src="https://api.ccttiot.com/smartmeter/img/static/uz3vQk44WkGnJPVjKrw1"
mode="aspectFill"></image>
<u-navbar title="高僧详情" :border-bottom="false" back-icon-color="#262B37" title-color='#695347' title-size='36'
height='50' id="navbar">
</u-navbar>
<custom-navbar title="高僧详情" />
<view class="container">
<view class="header">
<view class="content">
@ -50,8 +48,12 @@
import CommonEnum from "../../enum/common";
import MonkEnum from "../../enum/monk";
import {getMonkDetail} from "../../api/monk/monkDetail.js";
import CustomNavbar from "../../components/custom-navbar/custom-navbar.vue";
export default {
components: {
CustomNavbar
},
computed: {
MonkEnum() {
return MonkEnum

View File

@ -3,7 +3,6 @@
<!-- 自定义导航栏 -->
<custom-navbar
title="走进平山"
@back="onBack"
/>
<view class="header">
@ -28,10 +27,7 @@ export default {
}
},
methods: {
onBack() {
//
console.log('返回按钮被点击');
}
// @back
}
}
</script>