12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- <template>
- <view :class="{navbarTran: true, active: active}" :style="{height: `${placeholderHeight}px`}">
- <view :style="{height: `${barHeight}px`, marginTop:`${barTop}px`}">
- <uni-icons style="margin-left: 10px;" type="back" color="#000000" size="26" @click="back"></uni-icons>
- <text style="margin-left: 10px;">{{title}}</text>
- </view>
- </view>
- </template>
- <script>
- export default{
- name: "navbarTransparent",
- props:['title'],
- data(){
- return {
- barTop:0,
- barHeight:0,
- placeholderHeight:0,
- active:false,
- timer: 0
- }
- },
- onReady(){
- this.barTop = uni.getSystemInfoSync().statusBarHeight
- const menuButtonInfo = uni.getMenuButtonBoundingClientRect()
- this.barHeight = menuButtonInfo.height + (menuButtonInfo.top - this.barTop) * 2
- this.placeholderHeight = this.barHeight + this.barTop
- },
- onHide(){
- clearInterval(this.timer)
- },
-
- methods:{
- back(){
- uni.navigateBack({
- fail:()=>{
- uni.switchTab({
- url: "/pages/index/index"
- })
- }
- })
- },
-
- }
- }
- </script>
- <style lang="scss" scoped>
- .navbarTran{
- z-index: 100;
- position: fixed;
- top: 0;
- // height: 100rpx;
- width: 100%;
- background-color: transparent;
- transition: 0.3s all;
-
- >view{
- display: flex;
- align-items: center;
- justify-content: flex-start;
- }
- text{
- color:#000;
- font-size: 32rpx;
- text-shadow: 0.1px 0.1px 0.2px #000;
- }
-
- &.active{
- background-color: #fff;
- }
- }
- </style>
|