Commit 3681c797 by fanx
2 parents 77b0c9c7 10361d7f
<template> <template>
<section> <section v-wrap:height="'v'">
<div class="nav_bar" :class="{bgImgClass:isBgImg}" :style="navObj.barStyle"> <div class="nav_bar" :class="{bgImgClass:isBgImg}" :style="navObj.barStyle">
<!-- 左侧 自定义 --> <div class="nav_top_container" v-if="$slots.top">
<div class="nav_left" v-if="$slots.left" slot="left"> <slot name="top" />
<slot name="left" />
</div> </div>
<!-- 左侧 默认 箭头以及文字描述 --> <div class="nav_content_container">
<div class="nav_left" v-else @click="handleBack"> <!-- 左侧 自定义 -->
<i v-if="navObj.barLeftArrow" class="iconfont iconpreviewleft"></i> <div class="nav_left" v-if="$slots.left" slot="left">
{{navObj.barLeftText}} <slot name="left" />
</div>
<!-- 左侧 默认 箭头以及文字描述 -->
<div class="nav_left" v-else @click="handleBack">
<i v-if="navObj.barLeftArrow" class="iconfont iconpreviewleft"></i>
{{navObj.barLeftText}}
</div>
<!-- 标题栏 默认 自定义 -->
<div v-if="$slots.default" v-wrap:height="'v'">
<div class="nav_title" v-wrap:height="'v'">
<slot />
</div>
</div>
<!-- 标题栏 -->
<div class="nav_title" v-else>{{navObj.barTitle}}</div>
<!-- 右侧插槽 -->
<div class="nav_right" v-if="$slots.right" slot="right">
<slot name="right" />
</div>
</div> </div>
<!-- 标题栏 默认 自定义 --> <div class="nav_bottom_container" v-if="$slots.bottom">
<div class="nav_title" v-if="$slots.default"> <slot name="bottom" />
<slot />
</div>
<!-- 标题栏 -->
<div class="nav_title" v-else>{{navObj.barTitle}}</div>
<!-- 右侧插槽 -->
<div class="nav_right" v-if="$slots.right" slot="right">
<slot name="right" />
</div> </div>
</div> </div>
</section> </section>
...@@ -56,7 +66,7 @@ export default { ...@@ -56,7 +66,7 @@ export default {
} }
}, },
computed: { computed: {
navObj() { navObj () {
const meta = this.$route.meta const meta = this.$route.meta
let leftArrowStatus = true let leftArrowStatus = true
if (this.leftArrow != undefined) { if (this.leftArrow != undefined) {
...@@ -81,34 +91,69 @@ export default { ...@@ -81,34 +91,69 @@ export default {
}, },
}, },
methods: { methods: {
handleBack() { handleBack () {
if (this.showBack) { if (this.showBack) {
this.onBack() this.onBack()
} else { } else {
this.$router.back() this.$router.back()
} }
this.$nextTick
}
},
directives: {
wrap: {
inserted: function (el, binding, vnode, oldVnode) {
setTimeout(() => {
const { arg, value } = binding
const style = { width: 0, height: 0 }
for (let i = 0; i < el.childNodes.length; i++) {
const element = el.childNodes[i];
if (arg == 'height') {
if (value == 'h') {
style.height = Math.max(style.height, element.offsetHeight)
} else if (value == 'v') {
style.height = style.height + element.offsetHeight
}
} else if (arg == 'width') {
if (value == 'h') {
style.width = Math.max(style.height, element.offsetWidth)
} else if (value == 'v') {
style.width = style.height + element.offsetWidth
}
}
}
style.width && (el.style.width = `${style.width}px`)
style.height && (el.style.height = `${style.height}px`)
}, 0);
}
} }
} }
} }
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
@NavHeight: 45px; @NavHeight: 45px;
@PaddingSize: 15px;
section { section {
height: @NavHeight;
width: 100%; width: 100%;
position: relative; position: relative;
z-index: 10; z-index: 10;
.nav_bar { .nav_bar {
height: @NavHeight;
position: fixed; position: fixed;
left: 0; left: 0;
top: 0; top: 0;
width: 100%; width: 100%;
display: flex; padding: 0 @PaddingSize;
justify-content: space-between;
box-sizing: border-box; box-sizing: border-box;
padding: 0 20px;
.nav_content_container {
min-height: @NavHeight;
position: relative;
display: flex;
align-items: center;
justify-content: space-between;
}
} }
.bgImgClass { .bgImgClass {
background: url(../assets/icon/bg_navigation.png) !important; background: url(../assets/icon/bg_navigation.png) !important;
...@@ -136,6 +181,7 @@ section { ...@@ -136,6 +181,7 @@ section {
top: 0; top: 0;
height: 100%; height: 100%;
width: 100%; width: 100%;
min-height: @NavHeight;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!