封装导航栏的应用
This commit is contained in:
parent
aa5e70d5f6
commit
540e05c282
|
|
@ -15,7 +15,7 @@
|
||||||
```vue
|
```vue
|
||||||
<template>
|
<template>
|
||||||
<view class="page">
|
<view class="page">
|
||||||
<custom-navbar title="页面标题" @back="onBack" />
|
<custom-navbar title="页面标题" />
|
||||||
<!-- 页面内容,无需设置 margin-top -->
|
<!-- 页面内容,无需设置 margin-top -->
|
||||||
<view class="content">
|
<view class="content">
|
||||||
<text>页面内容</text>
|
<text>页面内容</text>
|
||||||
|
|
@ -29,11 +29,6 @@ import CustomNavbar from "@/components/custom-navbar/custom-navbar.vue";
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
CustomNavbar
|
CustomNavbar
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
onBack() {
|
|
||||||
console.log('返回按钮被点击');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -45,7 +40,6 @@ export default {
|
||||||
<custom-navbar
|
<custom-navbar
|
||||||
title="页面标题"
|
title="页面标题"
|
||||||
:backIcon="customBackIcon"
|
:backIcon="customBackIcon"
|
||||||
@back="onBack"
|
|
||||||
/>
|
/>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -61,7 +55,7 @@ export default {
|
||||||
### 添加右侧内容
|
### 添加右侧内容
|
||||||
|
|
||||||
```vue
|
```vue
|
||||||
<custom-navbar title="页面标题" @back="onBack">
|
<custom-navbar title="页面标题">
|
||||||
<template #right>
|
<template #right>
|
||||||
<view class="right-content">
|
<view class="right-content">
|
||||||
<text>右侧内容</text>
|
<text>右侧内容</text>
|
||||||
|
|
@ -82,7 +76,7 @@ export default {
|
||||||
|
|
||||||
| 事件名 | 说明 | 回调参数 |
|
| 事件名 | 说明 | 回调参数 |
|
||||||
|--------|------|----------|
|
|--------|------|----------|
|
||||||
| back | 点击返回按钮时触发 | - |
|
| back | 点击返回按钮时触发(可选,组件会自动执行返回逻辑) | - |
|
||||||
|
|
||||||
## Slots
|
## Slots
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,9 @@ export default {
|
||||||
},
|
},
|
||||||
handleBack() {
|
handleBack() {
|
||||||
if (this.showBack) {
|
if (this.showBack) {
|
||||||
|
// 先触发自定义事件,让父组件有机会处理
|
||||||
this.$emit('back');
|
this.$emit('back');
|
||||||
|
// 自动执行返回逻辑
|
||||||
uni.navigateBack({
|
uni.navigateBack({
|
||||||
delta: 1
|
delta: 1
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<view class="page">
|
<view class="page">
|
||||||
<u-navbar title="建制" :border-bottom="false" :background="bgc" back-icon-color="#262B37" title-color='#695347'
|
<custom-navbar title="建制" />
|
||||||
title-size='36' height='50' :title-style="{ fontWeight: 2000 }" id="navbar">
|
|
||||||
</u-navbar>
|
|
||||||
<view class="tile">
|
<view class="tile">
|
||||||
<view class="tile-item" v-for="(item, index) in 10" :key="index">
|
<view class="tile-item" v-for="(item, index) in 10" :key="index">
|
||||||
<image :src="tilesImageEnum.TILE" mode="aspectFit" class="tile-image"></image>
|
<image :src="tilesImageEnum.TILE" mode="aspectFit" class="tile-image"></image>
|
||||||
|
|
@ -44,8 +42,12 @@
|
||||||
<script>
|
<script>
|
||||||
import { tilesImageEnum } from '@/enum/institutionalStructure.js';
|
import { tilesImageEnum } from '@/enum/institutionalStructure.js';
|
||||||
import { getInstitutionalList } from '@/api/institutionalStructure.js';
|
import { getInstitutionalList } from '@/api/institutionalStructure.js';
|
||||||
|
import CustomNavbar from "../../components/custom-navbar/custom-navbar.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
components: {
|
||||||
|
CustomNavbar
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
bgc: {
|
bgc: {
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,7 @@
|
||||||
<image class="bg-image" src="https://api.ccttiot.com/smartmeter/img/static/uz3vQk44WkGnJPVjKrw1"
|
<image class="bg-image" src="https://api.ccttiot.com/smartmeter/img/static/uz3vQk44WkGnJPVjKrw1"
|
||||||
mode="aspectFill"></image>
|
mode="aspectFill"></image>
|
||||||
|
|
||||||
<u-navbar title="高僧详情" :border-bottom="false" back-icon-color="#262B37" title-color='#695347' title-size='36'
|
<custom-navbar title="高僧详情" />
|
||||||
height='50' id="navbar">
|
|
||||||
</u-navbar>
|
|
||||||
<view class="container">
|
<view class="container">
|
||||||
<view class="header">
|
<view class="header">
|
||||||
<view class="content">
|
<view class="content">
|
||||||
|
|
@ -50,8 +48,12 @@
|
||||||
import CommonEnum from "../../enum/common";
|
import CommonEnum from "../../enum/common";
|
||||||
import MonkEnum from "../../enum/monk";
|
import MonkEnum from "../../enum/monk";
|
||||||
import {getMonkDetail} from "../../api/monk/monkDetail.js";
|
import {getMonkDetail} from "../../api/monk/monkDetail.js";
|
||||||
|
import CustomNavbar from "../../components/custom-navbar/custom-navbar.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
components: {
|
||||||
|
CustomNavbar
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
MonkEnum() {
|
MonkEnum() {
|
||||||
return MonkEnum
|
return MonkEnum
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
<!-- 自定义导航栏 -->
|
<!-- 自定义导航栏 -->
|
||||||
<custom-navbar
|
<custom-navbar
|
||||||
title="走进平山"
|
title="走进平山"
|
||||||
@back="onBack"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<view class="header">
|
<view class="header">
|
||||||
|
|
@ -28,10 +27,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onBack() {
|
// 如果需要自定义返回逻辑,可以添加 @back 事件监听
|
||||||
// 可以在这里添加返回前的逻辑
|
|
||||||
console.log('返回按钮被点击');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user