| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <template>
- <view class="uni-navbar">
- <view class="uni-navbar-inner" :style="navbarStyle">
- <view class="left-content" @click="back">
- <text class="uni-icons uniui-back"></text>
- </view>
- <view class="uni-navbar-content">
- <slot>{{title}}</slot>
- </view>
- <view class="right-content">
- <slot name="right"></slot>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- name: "uni-navbar",
- props: {
- title: {
- type: String,
- default: '',
- },
- showLeft:{
- type: Boolean,
- default: true
- }
- },
- data() {
- return {
- statusBarHeight: 0
- };
- },
- computed: {
- navbarStyle() {
- return `margin-top:${this.statusBarHeight}px`
- },
- },
- created() {
- const sys = uni.getSystemInfoSync()
- const statusBarHeight = sys.statusBarHeight
- this.statusBarHeight = statusBarHeight
- },
- methods: {
- back() {
- uni.navigateBack({})
- }
- },
- }
- </script>
- <style>
- @import './uni-icons.css';
- .uni-icons {
- font-family: UniIconsLight;
- text-decoration: none;
- text-align: center;
- font-size: 22px;
- font-style: normal;
- color: #333;
- }
- .uni-navbar {
- border: 1px #eee solid;
- background-color: #fff;
- }
- .uni-navbar-inner {
- position: relative;
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- height: 45px;
- }
- .left-content,
- .right-content {
- display: flex;
- justify-content: center;
- align-items: center;
- width: 45px;
- height: 100%;
- }
- .uni-navbar-content {
- position: absolute;
- height: 100%;
- top: 0;
- bottom: 0;
- left: 45px;
- right: 45px;
- display: flex;
- justify-content: center;
- align-items: center;
- }
- </style>
|