// Utils import { createNamespace } from '../utils'; import { BORDER_BOTTOM } from '../utils/constant'; // Components import Icon from '../icon'; const [createComponent, bem] = createNamespace('nav-bar'); export default createComponent({ props: { title: String, fixed: Boolean, zIndex: [Number, String], leftText: String, rightText: String, leftArrow: Boolean, placeholder: Boolean, border: { type: Boolean, default: true, }, }, emits: ['click-left', 'click-right'], data() { return { height: null, }; }, mounted() { if (this.placeholder && this.fixed) { this.height = this.$refs.navBar.getBoundingClientRect().height; } }, methods: { genLeft() { const leftSlot = this.$slots.left?.(); if (leftSlot) { return leftSlot; } return [ this.leftArrow && , this.leftText && {this.leftText}, ]; }, genRight() { const rightSlot = this.$slots.right?.(); if (rightSlot) { return rightSlot; } if (this.rightText) { return {this.rightText}; } }, genNavBar() { return (
{this.genLeft()}
{this.$slots.title ? this.$slots.title() : this.title}
{this.genRight()}
); }, onClickLeft(event) { this.$emit('click-left', event); }, onClickRight(event) { this.$emit('click-right', event); }, }, render() { if (this.placeholder && this.fixed) { return (
{this.genNavBar()}
); } return this.genNavBar(); }, });