123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- <template>
- <view class="u-navbar">
- <view
- class="u-navbar__placeholder"
- v-if="fixed && placeholder"
- :style="{
- height: $u.addUnit($u.getPx(height) + $u.sys().statusBarHeight,'px'),
- }"
- ></view>
- <view :class="[fixed && 'u-navbar--fixed']">
- <u-status-bar
- v-if="safeAreaInsetTop"
- :bgColor="bgColor"
- ></u-status-bar>
- <view
- class="u-navbar__content"
- :class="[border && 'u-border-bottom']"
- :style="{
- height: $u.addUnit(height),
- backgroundColor: bgColor,
- }"
- >
- <view
- class="u-navbar__content__left"
- hover-class="u-navbar__content__left--hover"
- hover-start-time="150"
- @tap="leftClick"
- >
- <slot name="left">
- <u-icon
- v-if="leftIcon"
- :name="leftIcon"
- :size="leftIconSize"
- :color="leftIconColor"
- ></u-icon>
- <text
- v-if="leftText"
- :style="{
- color: leftIconColor
- }"
- class="u-navbar__content__left__text"
- >{{ leftText }}</text>
- </slot>
- </view>
- <slot name="center">
- <text
- class="u-line-1 u-navbar__content__title"
- :style="[{
- width: $u.addUnit(titleWidth),
- }, $u.addStyle(titleStyle)]"
- >{{ title }}</text>
- </slot>
- <view
- class="u-navbar__content__right"
- v-if="$slots.right || rightIcon || rightText"
- @tap="rightClick"
- >
- <slot name="right">
- <u-icon
- v-if="rightIcon"
- :name="rightIcon"
- size="20"
- ></u-icon>
- <text
- v-if="rightText"
- class="u-navbar__content__right__text"
- >{{ rightText }}</text>
- </slot>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import props from './props.js';
-
- export default {
- name: 'u-navbar',
- mixins: [uni.$u.mpMixin, uni.$u.mixin, props],
- data() {
- return {
- }
- },
- methods: {
-
- leftClick() {
-
- this.$emit('leftClick')
- if(this.autoBack) {
- uni.navigateBack()
- }
- },
-
- rightClick() {
- this.$emit('rightClick')
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- @import "../../libs/css/components.scss";
- .u-navbar {
- &--fixed {
- position: fixed;
- left: 0;
- right: 0;
- top: 0;
- z-index: 11;
- }
- &__content {
- @include flex(row);
- align-items: center;
- height: 44px;
- background-color: #9acafc;
- position: relative;
- justify-content: center;
- &__left,
- &__right {
- padding: 0 13px;
- position: absolute;
- top: 0;
- bottom: 0;
- @include flex(row);
- align-items: center;
- }
- &__left {
- left: 0;
-
- &--hover {
- opacity: 0.7;
- }
- &__text {
- font-size: 15px;
- margin-left: 3px;
- }
- }
- &__title {
- text-align: center;
- font-size: 16px;
- color: $u-main-color;
- }
- &__right {
- right: 0;
- &__text {
- font-size: 15px;
- margin-left: 3px;
- }
- }
- }
- }
- </style>
|