You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
< template >
< view class = "tabbar" @ touchmove.stop.prevent = " ( ) = > { } ">
<view class=" tabbar _ _content safe - area - inset - bottom ">
<view class=" tabbar _ _content _ _item "
v-for=" item in pages "
:class=" { 'tabbar__content__item-active' : pageUrl === item . pagePath } "
:key=" item . pagePath "
@tap.stop=" clickHandler ( item ) ">
<view class=" icon ">
<img class=" active - bkg " src=" / static / tabbar / active - bkg . svg " alt=" ">
<img class=" icon _ _inner " :src=" pageUrl === item . pagePath ? item . selectedMyIconPath : item . myIconPath " alt=" " >
</view>
<text class=" text ">{{ item.text }}</text>
</view>
</view>
</view>
</template>
<script>
import pages from '@/pages.json'
export default {
data() {
return {
pageUrl: '',
pages: []
};
},
created() {
this.pages = pages.tabBar.list
uni.hideTabBar();
// 获取引入了u-tabbar页面的路由地址, 该地址没有路径前面的" / "
let curPages = getCurrentPages();
// 页面栈中的最后一个即为项为当前页面, route属性为页面路径
this.pageUrl = curPages[curPages.length - 1].route;
},
methods: {
clickHandler (item) {
uni.switchTab({
url: '/' + item.pagePath
})
}
},
}
</script>
<style lang=" scss " >
. tabbar {
& _ _content {
height : 60 px ;
display : flex ;
justify - content : center ;
align - items : flex - end ;
background : # fff ;
position : fixed ;
bottom : 0 ;
left : 0 ;
width : 100 % ;
z - index : 998 ;
/* #ifndef APP-NVUE */
box - sizing : content - box ;
/* #endif */
& _ _item {
flex : 1 ;
display : flex ;
flex - direction : column ;
align - items : center ;
padding - bottom : 12 rpx ;
. icon {
width : 40 rpx ;
height : 40 rpx ;
// overflow: hidden;
z - index : 2 ;
position : relative ;
. active - bkg {
display : none ;
position : absolute ;
top : 0 ;
left : 0 ;
}
& _ _inner {
width : 40 rpx ;
height : 40 rpx ;
border - bottom : 40 rpx solid transparent ;
transform : translateZ ( 0 ) ;
// filter: drop-shadow(0 80rpx 0 #333);
}
}
. text {
font - size : 24 rpx ;
color : # 333 ;
margin - top : 12 rpx ;
}
& - active {
filter : drop - shadow ( 0 0 4 rpx # fff ) ;
. icon {
$activeSize : 94 rpx ;
width : $activeSize ;
height : $activeSize ;
. active - bkg {
display : inherit ;
width : $activeSize ;
height : $activeSize ;
}
& _ _inner {
$activeIcon : 50 rpx ;
width : $activeIcon ;
height : $activeIcon ;
transform : translateX ( calc ( ( # { $activeSize } - # { $activeIcon } ) / 2 ) ) translateY ( calc ( ( # { $activeSize } - # { $activeIcon } ) / 2 ) ) translateZ ( 0 ) ;
// filter: drop-shadow(calc((#{$activeSize} - #{$activeIcon}) / 2) calc((#{$activeSize} - #{$activeIcon}) / 2) 0 #fff);
// filter: drop-shadow(calc((#{$activeSize} - #{$activeIcon}) / 2) calc((#{$activeSize} - #{$activeIcon}) / 2 + 80rpx) 0 #fff);
}
}
. text {
color : # d05b58 ;
}
}
}
}
}
< / style >